Reputation: 1334
I'm working on an android app where I need to create a file and write/read on it using bufferedwrite and bufferedread. The file is declared in the activity as follows:
String string = "string";
File file = new File(this.getFilesDir(), string);
When I try to write to the file using this code, however:
BufferedWriter out = new BufferedWriter(new FileWriter(new File(file)));
out.write("I am a line of text written in" + file);
out.close();
I keep getting a "constructer File(File) is undefined" error. I believe the error has to do with the file declaration, but I'm not sure why.
Any help is greatly appreciated.
Upvotes: 0
Views: 523
Reputation: 690
String string = "string";
File file = new File(this.getFilesDir(), string);
BufferedWriter out = new BufferedWriter(new FileWriter(file));
out.write("I am a line of text written in" + file);
out.close();
Upvotes: 1