我在 android 上写了这段代码来了解 .txt 文件是否存在。
File file_a =new File("a.txt");
InputStream in3 = getResources().openRawResource(R.raw.b);
FileOutputStream out3 = null;
try { out3=openFileOutput("a.txt",Context.MODE_WORLD_WRITEABLE);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
byte[] buff3 = new byte[1024];
int read3 = 0;
try {
while ((read3 = in3.read(buff3)) > 0) {
out3.write(buff3, 0, read3);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
in3.close();
out3.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
boolean a=file_a.exists();
它总是返回false
。
我怎样才能解决这个问题?