‘壹’ 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属性。