5785 shaares
varijanta s podrskom za UTF-8
—
void fileWrite (String filename, String filecontent) {
BufferedWriter output = null;
try {
output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename, true), "UTF-8"));
output.write(filecontent);
}
catch (IOException e) {
println("Error writing to file");
e.printStackTrace();
}
finally {
if (output != null) {
try {
output.close();
}
catch (IOException e) {
println("Error closing the writer");
System.out.println(e.getMessage());
}
}
}
}
—
kompilirano odavde:
http://stackoverflow.com/questions/1625234/how-to-append-text-to-an-existing-file-in-java
http://stackoverflow.com/questions/6998905/java-bufferedwriter-object-with-utf-8