【发布时间】:2011-11-18 10:52:31
【问题描述】:
我在Android中尝试了一个简单的文件写入程序。
try
{
//File f1=new File("/sdcard/Prag.txt");
File f1=new File("J:\\Prag.txt");
BufferedWriter out = new BufferedWriter(new FileWriter(f1,true));
out.write("Pragadheesh" + "\n");
out.close();
} catch (IOException ioe)
{ioe.printStackTrace();}
但是异常被击中了。我该如何解决这个问题?
[编辑]:
我试过File f1=new File(Environment.getExternalStorageDirectory() + "//Prag.txt");
和 f1 值 = /mnt/sdcard/Prag.txt
但是异常仍然受到打击。我也在清单文件中更改了权限
[解决方案] 根据 Krishnabhadra 的回复,我必须确保您的 SDCard 没有安装在 PC 上
【问题讨论】:
标签: java android eclipse file-io