I have below code
try
{
FileWriter fileWriter = new FileWriter(\"C:\\\\temp\\\\test.txt\");
fileWriter.write(\"Hi this is sasi This t
Closing was missing. Hence not the last buffered data was not written to disk.
Closing also happens with try-with-resources. Even when an exception would be thrown. Also a flush
before close
is not needed, as a close flushes all buffered data to file.
try (FileWriter fileWriter = new FileWriter("C:\\temp\\test.txt"))
{
fileWriter.write("Hi this is sasi This test writing");
fileWriter.append("test");
}
catch (IOException ioException)
{
ioException.printStackTrace();
}