『壹』 android獲取本地文件名字
我寫了個例子,你看能用嗎?
package com.dragonred.android.utils;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.RandomAccessFile;
import java.text.SimpleDateFormat;
import java.util.Date;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Environment;
import android.util.Log;
public final class FileUtils {
public final static String PACKAGE_PATH = "com.dragonred.android";
// public final static String LOG_FILE_NAME = "smartprint.txt";
// public final static String LOG_FILE_PATH = STORE_DIRECTORY_PATH + File.separatorChar + LOG_FILE_NAME;
/**
* read key value from preference by key name
*
* @param context
* @param keyName
* @return
*/
public final static String readPreperence(Context context, String keyName) {
SharedPreferences settings = context.getSharedPreferences(
PACKAGE_PATH, 0);
return settings.getString(keyName, "");
}
/**
* write key name and key value into preference
*
* @param context
* @param keyName
* @param keyValue
*/
public final static void writePreperence(Context context, String keyName,
String keyValue) {
SharedPreferences settings = context.getSharedPreferences(
PACKAGE_PATH, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString(keyName, keyValue);
editor.commit();
}
/**
* delete key from preference by key name
*
* @param context
* @param keyName
*/
public final static void deletePreperence(Context context, String keyName) {
SharedPreferences settings = context.getSharedPreferences(
PACKAGE_PATH, 0);
SharedPreferences.Editor editor = settings.edit();
editor.remove(keyName);
editor.commit();
}
public final static String getContextFilePath(Context context, String fileName) {
return context.getFilesDir().getAbsolutePath() + File.separatorChar + fileName;
}
public final static boolean existContextFile(Context context, String fileName) {
String filePath = context.getFilesDir().getAbsolutePath() + File.separatorChar + fileName;
Log.d("filePath", filePath);
File file = new File(filePath);
if (file.exists()) {
return true;
}
return false;
}
public final static void saveContextFile(Context context, String fileName, String content) throws Exception {
FileOutputStream outputStream = context.openFileOutput(fileName, Context.MODE_PRIVATE);
outputStream.write(content.getBytes());
outputStream.close();
}
public final static void saveAppendContextFile(Context context, String fileName, String content) throws Exception {
FileOutputStream outputStream = context.openFileOutput(fileName, Context.MODE_APPEND);
outputStream.write(content.getBytes());
outputStream.close();
}
public final static void deleteContextFile(Context context, String fileName) throws Exception {
context.deleteFile(fileName);
}
public final static String readContextFile(Context context, String fileName) throws Exception {
FileInputStream inputStream = context.openFileInput(fileName);
byte[] buffer = new byte[1024];
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int len = -1;
while ((len = inputStream.read(buffer)) != -1) {
byteArrayOutputStream.write(buffer, 0, len);
}
byte[] data = byteArrayOutputStream.toByteArray();
byteArrayOutputStream.close();
inputStream.close();
return new String(data);
}
/**
* delete file or folders
* @param file
*/
public final static void deleteFile(File file) {
if (file.exists()) {
if (file.isFile()) {
file.delete();
} else if (file.isDirectory()) {
File files[] = file.listFiles();
for (int i = 0; i < files.length; i++) {
deleteFile(files[i]);
}
}
file.delete();
} else {
Log.d("deleteFile", "The file or directory does not exist!");
}
}
/**
* make directory on SD card
* @param dirPath
* @return
*/
public final static boolean makeDir(String dirPath) {
File dir = new File(dirPath);
if(!dir.isDirectory()) {
if (dir.mkdirs()) {
return true;
}
} else {
return true;
}
return false;
}
/**
* write log file
* @param filePath
* @param tag
* @param content
*/
public final static void writeLog(String filePath, String tag, String content) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String logDateTime = sdf.format(new Date());
writeFileByAppend(filePath, logDateTime + "---[" + tag + "]---" + content + "\n");
}
/**
* write file by append mode
* @param filePath
* @param content
*/
public final static void writeFileByAppend(String filePath, String content) {
// FileWriter writer = null;
// try {
// writer = new FileWriter(filePath, true);
// writer.write(content);
// } catch (IOException e) {
// e.printStackTrace();
// } finally {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
RandomAccessFile randomFile = null;
try {
randomFile = new RandomAccessFile(filePath, "rw");
long fileLength = randomFile.length();
randomFile.seek(fileLength);
randomFile.write(content.getBytes());
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
randomFile.close();
} catch (IOException e) {
e.printStackTrace();
}
}
// BufferedWriter out = null;
// try {
// out = new BufferedWriter(new OutputStreamWriter(
// new FileOutputStream(filePath, true), "UTF-8"));
// out.write(content);
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// try {
// out.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
}
/**
* write file by overwrite mode
* @param filePath
* @param content
*/
public final static void writeFile(String filePath, String content) {
// FileWriter writer = null;
// try {
// writer = new FileWriter(filePath, true);
// writer.write(content);
// } catch (IOException e) {
// e.printStackTrace();
// } finally {
// try {
// writer.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
BufferedWriter out = null;
try {
out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(filePath, false), "UTF-8"));
out.write(content);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* check SD card whether or not exist
* @param context
* @return
*/
public final static boolean checkSDCard(Context context) {
if (Environment.MEDIA_MOUNTED.equals(Environment
.getExternalStorageState())) {
return true;
} else {
// Toast.makeText(context, "Please check your SD card! ",
// Toast.LENGTH_SHORT).show();
return false;
}
}
/**
* read last line from file
* @param filePath
* @return
*/
public final static String readLastLinefromFile(String filePath) {
RandomAccessFile raf = null;
try {
File file = new File(filePath);
if (!file.exists()) {
return null;
}
raf = new RandomAccessFile(filePath, "r");
long len = raf.length();
if (len == 0L) {
return "";
} else {
long pos = len - 1;
while (pos > 0) {
pos--;
raf.seek(pos);
if (raf.readByte() == '\n') {
break;
}
}
if (pos == 0) {
raf.seek(0);
}
byte[] bytes = new byte[(int) (len - pos)];
raf.read(bytes);
return new String(bytes);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (raf != null) {
try {
raf.close();
} catch (Exception e2) {
}
}
}
return null;
}
}
『貳』 如何豎立的進度條.進度方向由下往上
你肯定喜歡
package com.anyka.seek;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.widget.AbsSeekBar;
public class VerticalSeekBar extends AbsSeekBar {
private Drawable mThumb;
private int height;
private int width;
public interface OnSeekBarChangeListener {
void onProgressChanged(VerticalSeekBar VerticalSeekBar, int progress, boolean fromUser);
void onStartTrackingTouch(VerticalSeekBar VerticalSeekBar);
void onStopTrackingTouch(VerticalSeekBar VerticalSeekBar);
}
private OnSeekBarChangeListener mOnSeekBarChangeListener;
public VerticalSeekBar(Context context) {
this(context, null);
}
public VerticalSeekBar(Context context, AttributeSet attrs) {
this(context, attrs, android.R.attr.seekBarStyle);
}
public VerticalSeekBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public void setOnSeekBarChangeListener(OnSeekBarChangeListener l) {
mOnSeekBarChangeListener = l;
}
void onStartTrackingTouch() {
if (mOnSeekBarChangeListener != null) {
mOnSeekBarChangeListener.onStartTrackingTouch(this);
}
}
void onStopTrackingTouch() {
if (mOnSeekBarChangeListener != null) {
mOnSeekBarChangeListener.onStopTrackingTouch(this);
}
}
void onProgressRefresh(float scale, boolean fromUser) {
Drawable thumb = mThumb;
if (thumb != null) {
setThumbPos(getHeight(), thumb, scale, Integer.MIN_VALUE);
invalidate();
}
if (mOnSeekBarChangeListener != null) {
mOnSeekBarChangeListener.onProgressChanged(this, getProgress(), fromUser);
}
}
private void setThumbPos(int w, Drawable thumb, float scale, int gap) {
int available = w+getPaddingLeft()-getPaddingRight();
int thumbWidth = thumb.getIntrinsicWidth();
int thumbHeight = thumb.getIntrinsicHeight();
available -= thumbWidth;
// The extra space for the thumb to move on the track
available += getThumbOffset() * 2;
int thumbPos = (int) (scale * available);
int topBound, bottomBound;
if (gap == Integer.MIN_VALUE) {
Rect oldBounds = thumb.getBounds();
topBound = oldBounds.top;
bottomBound = oldBounds.bottom;
} else {
topBound = gap;
bottomBound = gap + thumbHeight;
}
thumb.setBounds(thumbPos, topBound, thumbPos + thumbWidth, bottomBound);
}
protected void onDraw(Canvas c)
{
c.rotate(-90);
c.translate(-height,0);
super.onDraw(c);
}
protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
width = 22;
height = 160;
this.setMeasuredDimension(width, height);
}
@Override
public void setThumb(Drawable thumb)
{
mThumb = thumb;
super.setThumb(thumb);
}
protected void onSizeChanged(int w, int h, int oldw, int oldh)
{
super.onSizeChanged(h, w, oldw, oldh);
}
public boolean onTouchEvent(MotionEvent event) {
if (!isEnabled()) {
return false;
}
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
setPressed(true);
onStartTrackingTouch();
trackTouchEvent(event);
break;
case MotionEvent.ACTION_MOVE:
trackTouchEvent(event);
attemptClaimDrag();
break;
case MotionEvent.ACTION_UP:
trackTouchEvent(event);
onStopTrackingTouch();
setPressed(false);
break;
case MotionEvent.ACTION_CANCEL:
onStopTrackingTouch();
setPressed(false);
break;
}
return true;
}
private void trackTouchEvent(MotionEvent event) {
final int Height = getHeight();
final int available = Height - getPaddingBottom() - getPaddingTop();
int Y = (int)event.getY();
float scale;
float progress = 0;
if (Y > Height - getPaddingBottom()) {
scale = 0.0f;
} else if (Y < getPaddingTop()) {
scale = 1.0f;
} else {
scale = (float)(Height - getPaddingBottom()-Y) / (float)available;
}
final int max = getMax();
progress = scale * max;
setProgress((int) progress);
}
private void attemptClaimDrag() {
if (getParent() != null) {
getParent().(true);
}
}
public boolean dispatchKeyEvent(KeyEvent event) {
if(event.getAction()==KeyEvent.ACTION_DOWN)
{
KeyEvent newEvent = null;
switch(event.getKeyCode())
{
case KeyEvent.KEYCODE_DPAD_UP:
newEvent = new KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_DPAD_RIGHT);
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
newEvent = new KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_DPAD_LEFT);
break;
case KeyEvent.KEYCODE_DPAD_LEFT:
newEvent = new KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_DPAD_DOWN);
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
newEvent = new KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_DPAD_UP);
break;
default:
newEvent = new KeyEvent(KeyEvent.ACTION_DOWN,event.getKeyCode());
break;
}
return newEvent.dispatch(this);
}
return false;
}
}
『叄』 麻煩英語好的給翻譯一下
At
the
same
time,divide
the
person's
work,
study,
rest
and
life
behaviors
into
the
movement
of
model,
to
study
furniture
design,
according
to
the
set,
and
a
seat
and
lie
a
benchmark
to
regulate
the
basic
furniture
of
scale
and
furniture
of
mutual
relationship,
moverover,
furniture
design
is
also
different,
because
it
must
be
appropriate;
The
model
of
furniture
design,
material
selection
and
tie-in,
decorative
pattern,
color
design
is
more
with
the
people's
psychological
need.
As
the
old
『s
room
furniture
model
should
be
dignified,
elegant
color,
dark,
figure
case
is
rich;
Young
room
furniture
modellingshould
be
concise,
lightsome,
lively
colour,
beautiful
decoration,
etc.;
Children
room
furniture
made
the
leap,
cabinet
modelling
colour
round,
etc.
The
hard
and
soft
material,
color
changes
in
temperature,
the
adornment
such
as
standards
can
cause
people
strong
psychological
reaction.
Therefore,
the
good
furniture
design
can
rece
a
person
of
labor,
save
time,
make
people
healthy,
the
mood
please
yue,
and
the
good
furniture
design
benefited
from
the
right
to
use
the
principle
of
human
body
engineering.
No
doubt,
human
body
engineering
design
requirements
for
we
put
forward
the
new
height,
new
design
idea,
the
idea
is
arbitrary,
design
is
what
we
thought
this
new
age
will
need
to
design,
after
we
thought
of
design,
is
the
mature
design,
is
to
satisfy
the
design
of
artificial,
is
that
can
really
satisfy
now
generation
of
people's
design,
strong
promotion
is,
to
make
the
world
a
more
masterpieces.
ZuoJu
is
in
daily
life
we
use
most
of
the
supplies.
As
a
member
of
furniture,
the
importance
of
he
is
self-evident.
Therefore,
the
human
body
engineering
ZuoJu
knowledge
application
will
appear
particularly
important.
Once
the
chair
don't
accord
with
human
body
elements,
it
will
bring
a
lot
of
hemp
vexed.
Such
as
the
back
of
a
chair
if
the
improper
design
people
sit
above
can
feel
very
tired,
back
is
at
odds,
go
down
for
a
long
time,
could
be
influenced
by
different
degree
of
vertebral
ridge
of
the
damage.
On
the
network,
there
are
many
articles
about
human
body
engineering,
I
listed
a,
is
about
the
ambry
of
human
body
engineering,
said:
in
the
new
kitchen
concept,
the
kitchen
is
not
only
cook
place,
still
should
is
entertainment,
leisure,
friends,
communication
emotion
family
place.
"The
kitchen
new
life"
conveys
a
brand-new
life
concept.
Choose
purchase
in
ambry
not
only
pay
attention
to
the
choice
of
surface
sheets
cabinet
put
oneself
in
another's
position,
in
the
kitchen
when
the
design,
also
should
consider
reasonable
work
flow
and
people
body
engineering
design.
Reasonable
working
process
can
be
in
the
kitchen
works,
keep
a
leisurely
and
mentality,
comfortable
human
body
engineering
can
be
fully
scale
make
you
feel
the
warmth
of
human
nature,
operate
up
also
handy.
To
clean
tableware
as
an
example,
the
custom,
clean
cistern
upper
part
condole
ark
deposit
tableware,
if
not
in
the
measurement
of
science,
the
result
of
the
works,
as
in
the
cartoon
The
character,
the
xos
items
are
very
difficult.
If
according
to
the
principle
of
human
body
engineering
and
design,
widen
the
width
of
the
pool,
the
width
of
the
extension
after
as
work
station,
at
the
same
time,
rece
the
height
of
the
condole
ark,
just
to
change
a
bit,
you
can
take
the
intensity
of
the
tasks
to
a
minimum.
To
cook
food
as
an
example,
the
ordinary
work
station
and
condole
ark
of
the
design
is
reasonable
height
between,
operate
up,
cut
off
line
of
sight,
a
don't
be
careful,
and
meet
danger.
When
the
human
body
engineering
clever
into
ambry
design,
everything
is
different.
The
condole
ark
in
the
open
means,
for
example,
condole
ark
is
an
important
component
part
of
ambry,
store
items,
condole
ark
open
way,
directly
influenced
the
use
is
convenient.
The
traditional
open
means
taking
up
space,
lift
the
cupboard
door
be
convenient
to
use,
also
concive
to
beautiful.
In
the
big
drawer
cabinet
and
analogy
for
example.
If
we
use
cabinet
storage
items,
take
things
when,
want
to
open
cupboard
door,
squat
can
get
items.
If
use
drawer
storage
items,
pull
the
drawer,
can
see
all
items,
take
things
easy.
Everything
is
so
easy
and
comfortable,
human
body
engineering
design
in
the
application
of
ambry,
let
the
comfortable
life's
great
in
the
kitchen.
I
cited
its
original
text
explanation,
I
think
this
piece
of
the
article
says
is
very
reasonable,
direct
dissected
the
significance
of
human
body
engineering,
especially
with
hutch
room
furniture
as
a
representative
of.
Because
of
human
body
engineering
guidance,
the
furniture
design,
in
the
later
progress
must
be
set
off
one
body
furniture
design
storm;
The
big
bang
is
necessarily
century,
thought
big
gathering!
我找了一個好的網站,作了修改,不過肯定有錯,看你的了
『肆』 android,如何設置進度條的最小前進單位為5,用哪個屬性
給你個demo:
ProgressBar bar=new ProgressBar(this);
bar.setMax(100);
int i=0;
for(i=0;i<100;i++)
{
bar.setProgress(i+5);
};
最小前進單位是自己給定義的。SeekBar同理。
『伍』 第四輪問答題:View與ViewGroup有什麼區別
View類是Android上面繪制單元的最小集合,是繪制 按鍵觸發 已經可訪問屬性(可以理解為focus)的打包後的類ViewGroup類繼承了View類 並且添加了對View的位置及邏輯的管理功能 構造了View之間各類關系至於Layout View的一個布局框架 組合了一系列的View
『陸』 note3一開機就顯示smartcard service停止
smartcard service是加密sim、sd、tf卡的服務,用來做電子錢包的功能。因為這個服務保密性比較高,所以必須是官方下載的rom才能校驗通過。如果校驗不通過,則會出現你現在的狀況。如果你不需要用這個功能,可以把他忽視,不會對你有什麼影響。
對於這個服務功能的官方介紹,可以查看這個網址https://code.google.com/p/seek-for-android/
『柒』 高中英語單詞
Mole 1
academic [,?k?'demik] adj. 學術的
province ['pr?vins] n. 省
enthusiastic [in,θju:zi'?stik] adj.熱心的,
amazing [?'meizi?] adj.令人吃驚的;令人驚訝的
information [,inf?'mei??n] n. 消息
website [ web』sait] n.網站;網址
brilliant ['brilj?nt] adj.(口語)極好的
comprehension [,k?mpri'hen??n] n. 理解,領悟
instruction [in'str?k??n] n.(常作復數)指示;說明
method ['meθ?d] n. 方法
bored ['b?: d] adj.厭煩的;厭倦的
embarrassed [im'b?r?st] adj.尷尬的;難堪的;困窘的
attitude ['?titju:d] n. 態度
behaviour [bi'heivj?] n. 行為; 舉動
previous ['pri:vi?s] adj.以前的;從前的
description [di'skrip??n] n.記述; 描述
amazed [?'meizd] adj. 吃驚的;驚訝的
embarrassing [im'b?r?si?] adj.令人尷尬的;令人難堪的
technology [tek'n?l?d?i] n. 技術
impress [im'pres] vt.使印象深刻
correction [k?'rek??n] n. 改正;糾正
encouragement [in'k?rid?m?nt] n. 鼓勵;激勵
enjoyment [in'd??im?nt] n.享受;樂趣
fluency ['flu:?nsi] n.流利;流暢
misunderstanding [,mis?nd?'st?ndi?] n. 誤解
disappointed [,dis?'p?intid] adj. 失望的
disappointing [,dis?'p?inti?] adj.令人失望的
system ['sist?m] n. 制度;體系;系統
teenager ['ti:nid??] n.少年
disappear [,dis?'pi?] vi. 消失
move [mu:v] adj.搬家
assistant [?'sist?nt] n. 助手, 助理
cover ['k?v?] vt.包含
diploma [di'pl?um?] n. 文憑, 畢業證書
Mole 2
amusing [?'mju:zi?] adj. 有趣的; 可笑的
energetic [,en?'d?etik] adj. 精力充沛的
intelligent [in'telid??nt] adj. 聰明的
nervous ['n?:v?s] adj.緊張的;焦慮的
organized ['?:g?naizd] adj.有組織的;有系統的
patient ['pei??nt] adj.耐心的
serious ['si?ri?s] adj. 嚴肅的
shy [?ai] adj.害羞的;羞怯的
strict [strikt] a. 嚴格的;嚴厲的
impression [im'pre??n] n. 印象
avoid [?'v?id] vt.(故意)避開
hate [heit] vt.討厭;不喜歡
incorrectly [,ink?'rektli] adv.不正確地
completely [k?m'pli:tli] adv. 十分地;完全地
immediately [i'mi:di?tli] adv.立即;即刻
appreciate [?'pri:?ieit] vt.感激
admit [?d'mit] vt. 承認
scientific [,sai?n'tifik] adj. 科學的
literature ['lit?r?t??] n. 文學
loudly ['laudli] adv. 大聲地
wave [weiv] vt.揮(手);招(手)
joke [d??uk] n. 玩笑;笑話
summary ['s?m?ri] n.總結;摘要;提要
respect [ri'spekt] vt.&n.尊敬;尊重
grade [greid] n.(美)成績;分數
headmaster ['hed'mɑ:st?] n.校長
headmistress ['hed'mistris] n.女校長
period ['pi?ri?d] n.一段時間
revision [ri'vi??n] n.復習
translation [tr?ns'lei??n] n. 翻譯
timetable ['taimteibl] n. 時間表
topic ['t?pik] n.話題;題目
vacation [vei'kei??n] n. 假期
revise [ri'vaiz] vt.溫習(功課)
discipline ['disiplin] n.紀律
relationship [ri'lei??n?ip] n. 關系
formal ['f?:m?l] adj. 正式的
relaxed [ri'l?kst] adj.輕松的;鬆懈的;寬松的
similarly ['simil?li] adv.同樣地,類似地
Mole 3
helicopter ['helik?pt?] n.直升飛機
motorbike ['m?ut?, k] n.摩托車
tram [tr?m] n.電車
distance ['dist?ns] n. 距離
abandoned [?'b?nd?nd] adj.被遺棄的
camel ['k?ml] n. 駱駝
cassette [k?'set] n.錄音帶
desert ['dez?t] n. 沙漠
diamond ['dai?m?nd] n. 鑽石
expert ['eksp?:t] n. 專家
midnight ['midnait] n. 半夜
proct ['pr?d?kt] n. 產品
scenery ['si:n?ri] n. 風景; 景色
shoot [?u:t] vt.(shot,shot)射殺
soil [s?il] n. 土壤
journey ['d??:ni] n. 旅程
train [trein] vt. 訓練
circus ['s?:k?s] n. 馬戲團
seaside ['si:said] n. 海濱
stadium ['steidi?m] n. 運動場;體育場
eagle ['i:gl] n. 鷹
frighten ['fraitn] vt.是吃驚;驚嚇
kindergarten ['kind?,gɑ:tn] n.幼兒園
apartment [?'pɑ:tm?nt] n.(美)公寓;單元住宅
cartoon [kɑ:'tu:n] n. 卡通;漫畫
interview ['int?vju:] n.面試;面談
interviewer ['int?vju:?] n.(面試時的)主考官;面談者
event [i'vent] n. 事件
exhausted [ig'z?:stid] adj.疲憊不堪的
downtown ['daun'taun] adj.商業區的;市中心的
vacuum [`'v?kju?m] n. 真空; 空白
rail [reil] n.鐵軌
ceremony ['serim?ni] n.儀式
track [tr?k] n. 軌道
souvenir [,su:v?'ni?] n. 紀念品
Mole 4
survey [s?'vei] n. 調查
neighbourhood n.四鄰
local ['l?uk?l] adj.地方的;局部的
suburb ['s?b?:b] n.城郊;郊區
hometown [h?um'taun] n.家鄉
attractive [?'tr?ktiv] adj.有吸引力的;吸引人的
fortunate ['f?:t??nit] adj.幸運的;吉祥的
pretty ['priti] adv.很;相當
sound [saund] vi.聽起來
tourist ['tu?rist]n.旅遊者;觀光客
bother ['b?e?] vt.打擾;煩擾;麻煩
nuisance ['nju:sns] n.令人討厭的人或事
rent [rent] n. 租金
district ['distrikt] n.地域;區域;行政區
approach [?'pr?ut?] vt. 接近
harbour n.海港
gorgeous ['g?:d??s] adj.美麗的;宜人的
architecture ['ɑ:kitekt??] n. 建築
starve [stɑ:v] vi.餓死
park [pɑ:k] vt. 停車
traffic ['tr?fik] n. 交通
committee [k?'miti] n. 委員會
organization ['?:g?nai'z??n] n.組織
unemployed [,?nim'pl?id] adj.失業的;沒有工作的
household ['haush?uld] n.家屬;家人
occupation [,?kju'pei??n] n. 職業
professional [pr?'fe??nl] adj.專業的
manual ['m?nju?l] adj.用手的;手的
employment [im'pl?im?nt] n.就業;工作;職業
gallery ['g?l?ri] n.美術館;畫廊
exchange [iks't?eind?] vt. 交換
fascinating ['f?sineiti?] adj. 迷人的, 吸引人的
afford [?'f?:d] vt. 買得起;有能力支付
survive [s?'vaiv] vi.死裡逃生;大難不死
contact ['k?nt?kt] vt.聯絡;聯系(某人)
Mole 5
liquid ['likwid] n. 液體
expand [ik'sp?nd] vi.膨脹
contract ['k?ntr?kt] vi.收縮
substance ['s?bst?ns] n. 物質
mixture ['mikst??] n.混合物
oxygen ['?ks?d??n] n. 氧氣
electricity [,ilek'trisiti] n. 電
stage [steid?] n. 階段;時期
conclusion [k?n'klu:??n] n. 結論
aim [eim] n. 目標;目的
reaction [ri'?k??n] n. 反應
electrical [i'lektrik?l] adj.與電有關的;用電的
equipment [i'kwipm?nt] n. 設備;裝備
react [ri'?kt] vi.(化學)反應
potassium n. 鉀
sodium ['s?udi?m] n. 鈉
calcium ['k?lsi?m] n. 鈣
magnesium [m?g'ni:zi?m] n. 鎂
aluminium [,?lju'mini?m] n. 鋁
zinc [zi?k] n. 鋅
partial ['pɑ:??l] adj.部分的;局部的
copper ['k?p?] n. 銅
oxide ['?ksaid] n. 氧化物
rust [r?st] vi. 生銹
boil [b?il] vt.生銹
ordinary ['?:din?ri] adj. 普通的;平常的
steam [sti:m] n. 蒸汽;水氣
float [fl?ut] vi.漂浮
form [f?:m] vi.形成
dissolve [di'z?lv] vt. 溶解;分解;分離
balance ['b?l?ns] n.天平
crucible ['kru:sibl] n. 坩鍋
tongs [t??z] (復)夾子;小鉗子
flame [fleim] n. 火焰
facility [f?'siliti] n.(常作復數)設備;工具
lecture ['lekt??] n. 演講
department [di'pɑ:tm?nt] n.(大學的)科、系
astonished [?'st?ni?t] adj.吃驚的;驚愕的
Mole 6
contain [k?n'tein] vt. 包含;包括
access ['?kses] n.接近;通路
crash [kr??] vi.(計算機)崩潰
keyword ['ki: , w?:d] n.密碼;口令
log [l?g] vt.記錄;登錄
software ['s?ftw??] n. 軟體
breakdown ['breikdaun] n.故障
source [s?:s] n.來源;出處
accessible [?k'ses?bl] adj.可進入的; 可使用的
data ['deit?] n.(復)數據
defence [di'fens] n.保護;防衛
create [kri:'eit] vt. 創造;發明
network ['netw?:k] n. 網路
via [vai?] prep.途徑;經由
percentage [p?'sentid?] n.百分數;百分率
design [di'zain] vt. 設計
document ['d?kjum?nt] n. 文件
invention [in'ven??n] n. 發明
permission [p?'mi??n] n. 許可
military ['milit?ri] adj.軍事的;軍隊的
concentrate ['k?ns?ntreit] vi.集中(注意力、思想等)
definite ['definit] adj. 明確的
fantastic [f?n't?stik] adj.極好的;美妙的
independent [,indi'pend?nt] adj.獨立的
essay ['esei] n.文章
pass [p?s] vt.超過
frequently ['fri:kw?ntli] adv.時常;經常
disadvantage [,dis?d'vɑ:ntid?] n.弊端;缺點
average ['?v?rid?] adj.平均的
statistics [st?'tistiks] n.(復)統計數字
shorten ['??:tn] vt.縮短
sideways ['saidweiz] adv.橫著地;斜著地
survey 調查.測驗
add up 合計
upset adj 心煩意亂的;不安的,不適的
ignore不理睬.忽視
have got to 不得不;必須
concern(使)擔比:涉及;關繫到 n 擔心;關注.(利害)關系
be concerned about 關心.掛念
walk the dog 遇狗
loose adj 松的.松開的
vet 獸醫
go through 經歷;經受
Amsterdam 阿姆斯特丹(荷蘭首都)
Netherlands 荷蘭(西歐國家)
Jew 猶太人的;猶太族的
German 德國的.德國人的.德語的.
Nazi 納粹黨人 adj 納粹黨的
set down 記下;放下.登記
series 連續,系列
a series of 一連串的.一系列;一套
outdoors在戶外.在野外
spellbind 迷住;迷惑
purpose 故意
in order to 為了
sk 黃昏傍晚
at sk 在黃昏時刻
thunder vi 打雷雷鳴 n 雷,雷聲
entier adj 整個的;完全的,全部的
entily ady. 完全地.全然地.整個地
Power能力.力量.權力。
Face to face 面對面地
Curtain 窗簾;門簾.幕布
sty adj 積滿灰塵的
no longer /not … any longer 不再
partner 夥伴.合作者.合夥人
settle 安家.定居.停留vt 使定居.安排.解決
suffer vt & 遭受;忍受經歷
suffer from 遭受.患病
loneliness 孤單寂寞
highway高速公路
recover痊癒;恢復.
Get/be tired of 對…厭煩
Pack捆紮;包裝打行李 n 小包:包裹
pack ( sth ) up 將(東西)裝箱打包
suitcase手提箱;衣箱
overcoat大衣外套
teenager 十幾歲的青少年
get along with 與…相處.進展
gossip 閑話 閑談
fall in love 相愛;愛上
exactly 確實如此.正是;確切地山
disagree 不同意
grateful感激的.表示謝意的
dislike不喜歡.厭惡
join in 參加.加入
tip提示.技巧.尖;尖端.小費 傾斜;翻倒
secondly第二.其次
swap交換
item 項目.條款
subway <美>地鐵
elevator n 電梯;升降機
petrol <英>汽油( = <美> gasoline ) gas汽油.氣體.煤氣;毒氣。
official adj 官方的.正式的.公務的
voyage n 航行.航海
conquer 征服.佔領
because of 因為
native 本國的;本地的 n 本地人.本國人 come up 走近,上來.提出
apartment<美>公寓住宅.單元住宅
actually實際上,事實上
base根據 n 基部;基地,墓礎
at present 現在;目前
graal 逐漸的.逐步的
enrich 使富裕;充實,改善
vocabulary 詞彙.詞彙量.詞表
make use of 利用 使用
spelling拼寫.拼法
latter 較後的後平的;(兩者中)後者的 .
identity 本身.本體
fluent 流利的.流暢的
frequent adj 頻繁的.常見的
usage 使用.用法.詞語慣用法
command命令;指令;掌握
request請求;要求
dialect 方言
expression 詞語;表示表達
midwestern 中西部的.有中西部特性的 African adj 非洲的:非洲人的;非洲語言的 play a part ( in )扮演個角色:參與
lightning 閃電
straight 街區
cab計程車
journal日記;雜志.定期刊物
transport運送.運輸
Prefer更喜歡選擇某事物而不選擇其他事物disadvantage不利條件;不便之處
fare費用
route人路線.路途
flow 流動.流出 n 流動.流量
ever since 從那以後
persuade說服.勸說
cycle騎自行車
graate 畢業 n 大學畢業生
finally最後.終於
schele進度表
fond心喜愛的.慈愛的寵愛的
be fond of 喜愛;喜歡
short coming缺點
stubborn頑固的;固執的
organize 組織,成立
care about 關心;憂慮;
detail 細節;詳情
determine討決定;確定;下定決心
change one』s mind改變主意
journey 旅行.旅程
altitude 海拔高度.高處
make up one』s mind 下決心.決定
give in 投降.屈服.讓步
valley谷流域
waterfall 瀑布
Pace緩漫而行.踱步入一步.速度;步調 bend彎,拐角
meander蜿蜒緩慢流動飛
attitude.看法
forecast預測;預報
parcel小包;包裹
insurance 保險
wool羊毛.毛織
as usual 照常
reliable可信賴的.可靠的
pillow 枕頭;枕墊
midnight 午夜;子夜
at midnight 在午夜
flame火焰.光芒
beneath 在…下面
temple 廟宇寺廟
cave 洞穴.地窖
earthquake地震
right away 立刻馬上
well井
burst爆裂;爆發 突然破裂,爆發
million 百萬
event事件;大事
as if 彷彿.好像
at an end 結束;終結
nation民族.國家國民
canal 運河.水道
steam 蒸汽.水汽
dirt污垢;泥土
ruin 廢墟.毀滅.毀滅.使破產
in ruins 嚴重受損破敗不堪
suffering苦難.痛苦
extreme極度的
injure /損害.傷害
survivor倖存者.生還者;殘存物
destroy 破壞;毀壞.消滅
brick磚.磚塊
dam水壩.堰堤
track軌道.足跡.痕跡
useless無用的.無效的.無益的
shock(使)震涼震動n休克打擊
rescue 援救:營救
trap陷入困境 n 陷阱;困境
electricity 電,電流;電學
disaster 災難.災禍
dig out 掘出.發現
bury埋葬;掩埋.隱藏
mine礦.礦山礦井
miner礦工
shelter掩蔽.掩蔽處避身處
a(great)number of許多.大量的
title標題;頭銜.資格
damage損失損害
frighten使驚嚇;嚇唬
frightened受驚的.受恐嚇的
frightening心令人恐俱的
congratulation 祝賀.(復數)
Judge裁判員.法官以斷定;判斷;判決
sincerely真誠地.真摯地
express表示.表達 快車;速遞
outline 要點;大綱.輪廓
headline報刊的大字標題
quality質量:品質;勝質
active 積極的.活躍的
generous 慷慨的大方的
easygoing 隨和的.溫和寬容的
self 自我自身
selfish自私的
selfless無私的.忘我的
devote獻身.專心於
republic 共和國.共和政體
principle法則.原則;原理
nation民族主義國家主義
peaceful和平的.平靜的.安寧的
giant巨大的.龐大的
mankind人類
layer律師
guidance指導.領導
legal法律的.依照法律的
fee費(會費、學費等)
passbook 南非共和國有色人種的身份證
out of work 失業
helpful有希望的
league同盟;聯雙.聯合會
youth青年團
stage舞台階段;時期
vote 投票;選舉兒投票選票;表決
attack進攻;攻擊;抨擊
violence暴力;暴行
as a matter of fact 事實
blow up使充氣;爆炸
equal 相等的.平等的
in trouble 在危險、受罰、痛苦、憂慮的處境中
willing樂意的.自願的
unfair不公正的.不公平的
turn to 求助於;致力於
release釋放;發行
lose heart 喪失勇氣或信心
escape逃脫,逃走泄露
blanket毛毯.毯子
ecate教育
ecated受過教育的.有教養的
come to power 當權;上台
beg 請求;乞求
relative親戚親屬
terror恐怖 恐怖時期 恐怖活動
cruelty殘忍殘酷
reward報酬;獎金酬勞.獎賞
set up 建立
sentence 判決,宣判
president總統;會長;校長;行長
opinion 意見 看法 主張
cultural文化的
relic遺物.遺跡;紀念物
rare 稀罕的;稀有的,珍貴的
valuable 貴重的 有價值的
survive 倖免;倖存 生還
vase 花瓶.瓶
dynasty 朝代 王朝
in search of 尋找
amaze 吃驚,驚訝
amazing令人吃驚的
select 挑選;選擇
honey 蜜.蜂蜜
design設計.圖案.構思 vt 設計計劃.構思
fancy奇特的.異樣的 想像;設想,愛好
style風格.風度.類型
decorate裝飾.裝修
jewel 珠寶.寶石
artist藝術家
belong屬於.為的一員
belong to 屬於
in return 作為報答.回報
troop群.組.軍隊
reception 接待,招待會.接收
at war 處於交戰狀態
remove移動;搬開
less than 少於
wooden 木製的
doubt懷疑.疑惑 vt 懷疑不信
mystery 神秘.神秘的事物
former以前的.從前的
worth值得的,相當於…的價值.價值.作用值錢的rebuild重建
local本地的;當地的
apart分離地,分別地
take apart 拆開
painting繪畫;畫
castle城堡
trial審判.審訊,試驗
evidence 根據,證據
explode爆炸
entrance 入口
sailor水手;海員;船員
sink 下沉;沉下
maid少女.女僕
Berlin柏林(德國首都)
Think highly of 看重;器重
informal非正式的
debate爭論;辯論
ancient adj 古代的.古老的
compete vi 比賽競爭
competitor n 競爭者
take part in 參加;參與
medal n 獎章;勛章;紀念章
stand for 代表:象徵,表示
mascot n 吉祥物
Greece希臘
Greek 希臘人的;希臘語的 n 希臘人;希臘語 magical adj 巫術的.魔術的.有魔力的
volunteer志願者.志願兵.志願的,義務的
homeland 祖國;本國
regular adj 規則的.定期的.常規的
basis 基礎,根據
athlete n 運動員;運動選手
admit容許.承認.接納
slave 奴隸
nowadays 現今.現在
gymnastics 體操;體能訓練
athletics 體育運動.競技
stadium (露天大型)體育場
gymnasium ( gym ) 體育館、健身房
as well 也;又.還
host 做東;主辦;招待 n 主人
responsibility n 責任.職責
olive 橄欖樹.橄欖葉;橄欖枝;橄欖色
wreath 花圈、花冠、圈狀物卿
replace 取代替換.代替
motto 座右銘;格言;警句
swift 快的.迅速的
similarity 相像性:相似點
Athens 雅典(希臘首都)
charge 收費.控訴.費用.主管
in charge主管 看管
physical adj 物理的.身體的
poster 海報,招貼
advertise 做廣告.登廣告
princess 公主
glory 光榮.榮譽
bargain 討價還價.講條件.便宜貨
prince王子
hopeless 心沒有希望的;絕望的
foolish adj 愚蠢的,傻的
goddess 女神
pain 疼痛.痛苦
one after another 陸續地.一個接一個地
deserve 應受.值得
striker (足球的)前鋒
abacus n 算盤
calculate n 計算器
PC( = personal comPuter )個人電腦,個人計算laptop 手提電腦
PDA ( personal digital assistant )掌上電腦 個人數碼助理
analytical adj 分析的
calculate計算
universal adj 普遍的.通用的.宇宙的
simplify 簡化
sum 總數.算術題.金額
operator (電腦)操作員;接線員
logical 邏輯的;合情理的
logically 邏輯上;合邏輯地.有條理地
technology工藝.科技.技術
technological adj 科技的
revolution革命
artificial 人造的.假的
intelligence 智力:聰明智能
intelligence adj 智能的:聰明的
solve 解決.解答
mathematical數學的
from … on 從時起
reality 真實.事實.現實
designer 設計師
personal 私人的.個人的.親自的
personally 就個人而言,親自
tube 管;管子;電子管
transistor 碎片;晶元
as a result 結果
total adj 總的:整個的 n 總數.合計
so … that … 如此.以致於
network網路;網狀物
web 網
application 應用:用途;申請
finance金融;財經
mobile 可移動的.機動的
rocket 火箭
explore 探索.探側.探究
Mars火星
Anyhow (也作 anyway )無論如何.即使如此 goal 目標.目的;球門;(進球)得分
happiness 幸福;快樂
human rare人類
supporting adj 支持的,支撐的
download 下載
programmer 程序員;程序師
virus病毒
android 機器人
signal發信號 信號
teammate同伴;夥伴
in away 在某種程度上
coach 教練
arise出現;發生
with the help of 在的幫助下
electronic adj 電子的
appearance 外觀.外貌;出現
character 勝格.特點
mop 拖把
deal with 處理
watch over 看守,監視
naughty 頑皮的,淘氣的
niece 侄女
spoil 損壞
wildlife 野生動植物
protection 保護
habitat 棲息地
threaten 恐嚇
decrease 減少
die out 滅絕
loss 損失
reserve 保護區
hunt 打獵
zone 地域 地帶
in peace 和平地
species 種類 物種
carpet 地毯
respond 回答 相應
distant 遠的 遠處的
fur 毛皮 毛 軟毛
antelope 羚羊
relief (痛苦或憂慮的)減輕或解除
in relief 如釋重負,鬆了口氣
laughter 笑 笑聲
burst into laughter 突然笑起來
mercy 仁慈
certain 確定的,某一,一定
importance 重要(性)
rub 擦 摩擦
protect…from 保護…不受…(危害)
mosquito 蚊子
millipede 千足蟲
insect 昆蟲
contain 包含 容納 容忍
powerful 強大的 有力的
affect 影響 感動 侵襲
attention 注意 關注 注意力
pay attention to 注意
appreciate 鑒賞 感激 意識到
succeed 成功
secure 安全的
income 收入
employ 僱傭 利用
harm 損害 危害
bite 叮,咬,刺痛
extinction 滅絕 消亡
dinosaur 恐龍
come into being 形成,產生
inspect 檢查 視察
unexpected 沒料到的 意外的
incident 事件 事變
st 灰塵,塵土
according to 按照,根據…所說
fierce 兇猛的,猛烈的
so that 以致於 結果
roll 滾動 搖擺
orchestra 管弦樂隊
rap 說唱樂
folk 民間的
jazz 爵士樂
choral 合唱隊的
musician 音樂家
dream of 夢見 夢想
pretend 假裝,假扮
to be honest 說實在的,說實話
attach 繫上 附加 連接
attach to 認為有
form 組成.形成構成
fame名聲 名望
passer-by 過路人.行人
earn賺;掙得;獲得
extra 額外的 外力
perform表演;履行;執行
pub酒館 酒吧
cash 現金
in cash 用現金;有現錢
studio工作室.演播室
millionaire 百萬富翁;富豪
play jokes on 戲弄
actor 男演員;行動者
rely依賴.依靠
rely on 依賴 依靠
broadcast 播;播放
humorous 幽默的.詼諧的
familiar熟悉的;常見的;親近的
be /get familiar with 熟悉 與…熟悉起來
or so 大約
break up 碎;分裂;解體
addition吸引人的、有吸引力的
sort out 分類
excitement 興奮.刺激
dip浸;蘸
lily百合花
brief 簡短的;簡要的 n 摘要;大綱
devotion投人;熱愛
sensitive v / adj 敏感的;易受傷害的.靈敏的 painful adj 痛苦的 疼痛的
above all 最重要首先
『捌』 Android使用RandomAccessFile讀取TXT文件seek()之後讀取會部分亂碼
public interface RandomAccessList 實現所使用的標記介面,用來表明其支持快速(通常是固定時間)隨機訪問。此介面的主要目的是允許一般的演算法更改其行為,從而在將其應用到隨機或連續訪問列表時能提供良好的性能。 將操作隨機訪問列表的最佳演算法(如 ArrayList)應用到連續訪問列表(如 LinkedList)時,可產生二次項的行為。如果將某個演算法應用到連續訪問列表,那麼在應用可能提供較差性能的演算法前,鼓勵使用一般的列表演算法檢查給定列表是否為此介面的一個 instanceof,如果需要保證可接受的性能,還可以更改其行為。 現在已經認識到,隨機和連續訪問之間的區別通常是模糊的。例如,如果列表很大時,某些 List 實現提供漸進的線性訪問時間,但實際上是固定的訪問時間。這樣的 List 實現通常應該實現此介面。實際經驗證明,如果是下列情況,則 List 實現應該實現此介面,即對於典型的類實例而言,此循環: for (int i=0, n=list.size(); i < n; i++) list.get(i); 的運行速度要快於以下循環: for (Iterator i=list.iterator(); i.hasNext(); ) i.next(); 此介面是 Java Collections Framework 的成員。
『玖』 如何獲取android系統的字體名稱
在java環境中有一個專門的獲取ttf文件的頭信息的Font類
Font f = Font.createFont(Font.TRUETYPE_FONT, new FileInputStream("seguisym.ttf"));
String name = f.getName();
System.out.println(name);
但是在android環境下,我們無法直接用到該類去解析TTF文件,下面我將附上代碼來解析ttf文件
TTFParser.Java
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
/**
* TTF Font file parser
* <p>
* sample:
* <code><pre>
* File fs = new File("C:\\Windows\\Fonts");
* File[] files = fs.listFiles(new FilenameFilter() {
* public boolean accept(File dir, String name) {
* if (name.endsWith("ttf")){ return true;}
* return false;
* }
* });
* for (File file : files) {
* TTFParser parser = new TTFParser();
* parser.parse(file.getAbsolutePath());
* System.out.println("font name: " + parser.getFontName());
* }
* </pre></code>
* <p/>
* Copyright: Copyright (c) 12-8-6 下午3:51
* <p/>
* Version: 1.0
* <p/>
*/
public class TTFParser {
public static int COPYRIGHT = 0;
public static int FAMILY_NAME = 1;
public static int FONT_SUBFAMILY_NAME = 2;
public static int UNIQUE_FONT_IDENTIFIER = 3;
public static int FULL_FONT_NAME = 4;
public static int VERSION = 5;
public static int POSTSCRIPT_NAME = 6;
public static int TRADEMARK = 7;
public static int MANUFACTURER = 8;
public static int DESIGNER = 9;
public static int DESCRIPTION = 10;
public static int URL_VENDOR = 11;
public static int URL_DESIGNER = 12;
public static int LICENSE_DESCRIPTION = 13;
public static int LICENSE_INFO_URL = 14;
private Map<Integer, String> fontProperties = new HashMap<Integer, String>();
/**
* 獲取ttf font name
* @return
*/
public String getFontName() {
if (fontProperties.containsKey(FULL_FONT_NAME)) {
return fontProperties.get(FULL_FONT_NAME);
} else if (fontProperties.containsKey(FAMILY_NAME)) {
return fontProperties.get(FAMILY_NAME);
} else {
return null;
}
}
/**
* 獲取ttf屬性
* @param nameID 屬性標記,見靜態變數
* @return 屬性值
*/
public String getFontPropertie(int nameID) {
if (fontProperties.containsKey(nameID)) {
return fontProperties.get(nameID);
} else { return null; }
}
/**
* 獲取ttf屬性集合
* @return 屬性集合(MAP)
*/
public Map<Integer, String> getFontProperties() { return fontProperties; }
/**
* 執行解析
* @param fileName ttf文件名
* @throws IOException
*/
public void parse(String fileName) throws IOException {
fontProperties.clear();
RandomAccessFile f = null;
try {
f = new RandomAccessFile(fileName, "r");
parseInner(f);
} finally {
try {
f.close();
}catch (Exception e) {
//ignore;
}
}
}
private void parseInner(RandomAccessFile randomAccessFile) throws IOException {
int majorVersion = randomAccessFile.readShort();
int minorVersion = randomAccessFile.readShort();
int numOfTables = randomAccessFile.readShort();
if (majorVersion != 1 || minorVersion != 0) { return; }
//jump to TableDirectory struct
randomAccessFile.seek(12);
boolean found = false;
byte[] buff = new byte[4];
TbleDirectory tableDirectory = new TableDirectory();
for (int i = 0; i < numOfTables; i++) {
randomAccessFile.read(buff);
tableDirectory.name = new String(buff);
tableDirectory.checkSum = randomAccessFile.readInt();
tableDirectory.offset = randomAccessFile.readInt();
tableDirectory.length = randomAccessFile.readInt();
if ("name".equalsIgnoreCase(tableDirectory.name)) {
found = true;
break;
}else if (tableDirectory.name == null || tableDirectory.name.length() == 0) {
break;
}
}
// not found table of name
if (!found) { return; }
randomAccessFile.seek(tableDirectory.offset);
NameTableHeader nameTableHeader = new NameTableHeader();
nameTableHeader.fSelector = randomAccessFile.readShort();
nameTableHeader.nRCount = randomAccessFile.readShort();
nameTableHeader.storageOffset = randomAccessFile.readShort();
NameRecord nameRecord = new NameRecord();
for (int i = 0; i < nameTableHeader.nRCount; i++) {
nameRecord.platformID = randomAccessFile.readShort();
nameRecord.encodingID = randomAccessFile.readShort();
nameRecord.languageID = randomAccessFile.readShort();
nameRecord.nameID = randomAccessFile.readShort();
nameRecord.stringLength = randomAccessFile.readShort();
nameRecord.stringOffset = randomAccessFile.readShort();
long pos = randomAccessFile.getFilePointer();
byte[] bf = new byte[nameRecord.stringLength];
long vpos = tableDirectory.offset + nameRecord.stringOffset + nameTableHeader.storageOffset;
randomAccessFile.seek(vpos);
randomAccessFile.read(bf);
String temp = new String(bf, Charset.forName("utf-16"));
fontProperties.put(nameRecord.nameID, temp);
randomAccessFile.seek(pos);
}
}
@Override
public String toString() {
return fontProperties.toString();
}
private static class TableDirectory {
String name; //table name
int checkSum; //Check sum
int offset; //Offset from beginning of file
int length; //length of the table in bytes
}
private static class NameTableHeader {
int fSelector; //format selector. Always 0
int nRCount; //Name Records count
int storageOffset; //Offset for strings storage,
}
private static class NameRecord {
int platformID;
int encodingID;
int languageID;
int nameID;
int stringLength;
int stringOffset; //from start of storage area
}
}
『拾』 android mediaplayer可以播放flash嗎
Android2.2之後才支持安裝Flash插件並在WebView播放Flash視頻,初步想法是給Activity設置一個全屏的WebView,然後傳入一個Flash地址。MediaPlayer類實質上是一個控制器,用於播放OSMF中所支持的任何媒體元素類型。
因此,如果為一個MediaPlayer對象提供ImageElement對象,則它可以生成一幅圖像;如果為一個MediaPlayer對象傳遞VideoElement對象,則它可以渲染一個視頻。
下面列出了由MediaPlayer對象所呈現的每一個公共屬性。
● audioPan:一個數字,表示媒體的pan屬性。
● autoDynamicStreamSwitch:一個布爾值,指示媒體是否自動在動態流之間切換。
● autoPlay:一個布爾值,定義媒體是否在載入操作成功完成後立即開始播放。
● autoRewind:一個布爾值,定義媒體在回放完成後是否返回到回放起始位置。
● buffering:一個布爾值,指示媒體當前是否正在緩沖。
● bufferLength:一個數字,指示當前媒體緩沖區中的內容長度,以秒為單位。
● bufferTime:一個數字,指示媒體緩沖區的適宜長度,以秒為單位。
● bytesLoaded:一個數字,返回媒體已經載入內容的位元組數。
● bytesLoadedUpdateInterval:一個數字,表示為bytesLoaded屬性分派改變事件的間隔時間。
● bytesTotal:一個數字,表示媒體將要載入的總位元組數。
● canBuffer:一個布爾值,指示媒體是否可以緩沖。
● canLoad:一個布爾值,指示媒體是否可以載入。
● canPause:一個布爾值,指示媒體是否可以暫停。
● canPlay:一個布爾值,指示媒體是否可以播放。
● canSeek:一個布爾值,指示媒體是否可以定址。
● currentDynamicStreamIndex:一個整數,代表當前正在渲染的動態媒體流的索引。
● currentTime:一個數字,返回播放頭的當前時間,以秒為單位。
● currentTimeUpdateInterval:一個數字,定義當前時間分派變化事件之間的時間間隔,以毫秒為單位。
● displayObject:媒體的DisplayObject對象。
● drmEndDate:一個日期,指示回放窗口的結束日期。
● drmPeriod:一個數字,返回回放窗口的長度,以秒為單位。
● drmStartDate:一個日期,指示回放窗口的開始日期。
● drmState:一個字元串,指示該媒體DRM的當前狀態。
● ration:一個數字,表示媒體回放的持續時間,以秒為單位。
● dynamicStreamSwitching:一個布爾值,指示當前是否正在進行動態媒體流切換。
● hasAudio:一個布爾值,指示媒體是否包含音頻。
● hasDRM:一個布爾值,指示媒體元素是否具有DRMTrait。
● isDVRRecording:一個布爾值,指示媒體是否支持DVR以及當前是否正在錄制。
● isDynamicStream:一個布爾值,指示媒體是否由動態流組成。
● loop:一個布爾值,指示媒體是否應該在回放完成之後再次播放。
● maxAllowedDynamicStreamIndex:一個整數,表示最大允許的動態流索引。
● media:一個MediaElement對象,定義媒體播放器當前正在控制的源媒體元素。
● mediaHeight:一個數字,定義媒體的高度,以像素為單位。
● mediaWidth:一個數字,定義媒體的寬度,以像素為單位。
● muted:一個布爾值,指示媒體當前是否靜音。
● numDynamicStreams:一個整數,表示動態流索引的總數。
● paused:一個布爾值,指示媒體當前是否暫停。
● playing:一個布爾值,指示當前媒體是否正在播放。
● seeking:一個布爾值,指示媒體當前是否正在定址。
● state:一個字元串,表示媒體的當前狀態。
● temporal:一個布爾值,指示媒體是否為暫時性的。
● volume:一個數字,表示媒體的音量。
MediaPlayer還提供了許多方便的函數用於控制媒體,包括
● authenticate(username:String = null, password:String = null):用於認證媒體。
● authenticateWithToken(token:Object):使用用做令牌的對象來認證媒體。
● canSeekTo(seconds:Number):用於確定媒體是否可定址到指定時間,以秒為單位。
● (index:int):用於獲取指定動態流索引的碼率,以千位元組為單位。
● pause():用於暫停媒體,如果它還沒有暫停的話。
● play():用於播放媒體,如果當前它沒有處於播放狀態的話。
● seek(time:Number):用於跳轉到媒體文件中的指定時間。
● stop():用於停止回放並返回到媒體文件的開頭。
● switchDynamicStreamIndex(index:int):用於切換到特定動態流索引。
對於OSMF項目,將需要導入MediaPlayer;它可以在org.osmf.media包中找到。
import org.osmf.media.MediaPlayer;
為了利用一個AudioElement對象,需要創建一個MediaPlayer對象,然後將AudioElement對象賦值給MediaPlayer對象的media屬性。