Java android filewriter错误和应用程序退出
我尝试使用此代码编写文件,但不起作用: (我还添加了许可)Java android filewriter错误和应用程序退出,java,android,filewriter,Java,Android,Filewriter,我尝试使用此代码编写文件,但不起作用: (我还添加了许可) }eclipse中没有错误是在编译和运行保存方法时请检查文件路径。我认为你走错了路。尝试在外部存储器上创建文件。@codo您的主题说“android filewriter错误,应用程序退出”,那么问题出在哪里?这意味着如果我单击“侧面停止”按钮 public void save(View view){ try{ String data = " This content will append to the end of
}eclipse中没有错误是在编译和运行保存方法时请检查文件路径。我认为你走错了路。尝试在外部存储器上创建文件。@codo您的主题说“android filewriter错误,应用程序退出”,那么问题出在哪里?这意味着如果我单击“侧面停止”按钮
public void save(View view){
try{
String data = " This content will append to the end of the file";
File file =new File("javaio-appendfile.txt");
//if file doesnt exists, then create it
if(!file.exists()){
file.createNewFile();
}
//true = append file
FileWriter fileWritter = new FileWriter(file.getName(),true);
BufferedWriter bufferWritter = new BufferedWriter(fileWritter);
bufferWritter.write(data);
bufferWritter.close();
System.out.println("Done");
}catch(IOException e){
e.printStackTrace();
}