String path = Environment.getExternalStorageDirectory().getPath();
String name = path+"//"+"20131109.txt";
File file = new File(name);
String content="just a test";
try {
FileOutputStream outStream =new FileOutputStream(file);
outStream.write(content.getBytes());
outStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String name = path+"//"+"20131109.txt";
File file = new File(name);
String content="just a test";
try {
FileOutputStream outStream =new FileOutputStream(file);
outStream.write(content.getBytes());
outStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
本文提供了一个在Android环境中向外部存储写入文本文件的示例代码。通过使用FileOutputStream,该示例展示了如何创建一个名为20131109.txt的文件,并将字符串'justatest'写入到该文件中。
652

被折叠的 条评论
为什么被折叠?



