Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java android filewriter错误和应用程序退出_Java_Android_Filewriter - Fatal编程技术网

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();
    }