27.02.2014 Views

Android 开发教程

Android 开发教程

Android 开发教程

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

-----------------------------------<strong>Android</strong> 编 程 基 础<br />

android:layout_width="80px"<br />

android:layout_height="wrap_content"<br />

android:text=" 打 开 "<br />

android:layout_x="2px"<br />

android:layout_y="378px"><br />

<br />

<br />

<br />

<br />

4<br />

文 件 存 储<br />

/* 定 义 IO 对 象 */<br />

private String Text_of_input;<br />

private OutputStream os;<br />

Text_of_input = inputArt.getText().toString();<br />

// 得 到 用 户 输 入 字 符<br />

try {<br />

os = this.openFileOutput("txtME", MODE_PRIVATE);<br />

// 打 开 一 个 文 件 输 出 流 。 名 称 为 txtME, 模 式 为 不 覆 盖<br />

os.write(Text_of_input.getBytes());<br />

// 把 内 容 写 入 文 件<br />

} catch (FileNotFoundException e) {<br />

// TODO Auto-generated catch block<br />

} catch (IOException e) {<br />

// TODO Auto-generated catch block<br />

} finally {<br />

try {<br />

}<br />

// 关 闭 文 件 输 出 流<br />

os.close();<br />

} catch (IOException e) {<br />

// TODO Auto-generated catch block<br />

}<br />

5 文 件 读 取<br />

/* 定 义 IO 对 象 */<br />

private String Text_of_output;<br />

private InputStream is;<br />

5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!