【发布时间】:2012-11-20 20:24:06
【问题描述】:
尝试在特定目录中创建文件,但它显示错误 FileNotFound。为什么? 我在使用不可能的路径吗?我真的不知道,但似乎代码应该可以工作。
String day=/1;
String zn="/zn";
File_name=zn
String root= Environment.getExternalStorageDirectory().toString();
File_path=root+day;
File file1 = new File(File_path,File_name);
file1.mkdirs();
if(!file1.exists()) {
try {
file1.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
OutputStream fos= new FileOutputStream(file1);
String l,d,p;
l = lessnum.getText().toString();
d = desc.getText().toString();
p = place.getText().toString();
fos.write(l.getBytes());
fos.write(d.getBytes());
fos.write(p.getBytes());
fos.close();
【问题讨论】:
标签: java android eclipse outputstream fileoutputstream