D
DX
I need to append a string to a file in this way:
/////////////////////////////////////////////
String text;
while(some condition){
text = new value;
Append "text" to file named "OutputFile.txt";
}
Append "text" to file named "OutputFile.txt" again;
Other codes;
Append "text" to file named "OutputFile.txt" again;
......
end of program;
//////////////////////////////////////////
I have tried to use:
////
BufferedWriter out = new BufferedWriter(new FileWriter("OutputFile.txt",
true));
while(some condition){
text = new value;
out.write(text);
}
other codes;
out.write(text);
out.close();
////
but it doesn't behave the way I expected.
What I want is: as the program runns at different stage, I need to have the
capability of appending a string to a specific file at any point.
Is there such a method that can allow me to do so in Java?
Thank you for your help!
-New Java user
/////////////////////////////////////////////
String text;
while(some condition){
text = new value;
Append "text" to file named "OutputFile.txt";
}
Append "text" to file named "OutputFile.txt" again;
Other codes;
Append "text" to file named "OutputFile.txt" again;
......
end of program;
//////////////////////////////////////////
I have tried to use:
////
BufferedWriter out = new BufferedWriter(new FileWriter("OutputFile.txt",
true));
while(some condition){
text = new value;
out.write(text);
}
other codes;
out.write(text);
out.close();
////
but it doesn't behave the way I expected.
What I want is: as the program runns at different stage, I need to have the
capability of appending a string to a specific file at any point.
Is there such a method that can allow me to do so in Java?
Thank you for your help!
-New Java user