Hi,
Just adding the line fw.flush() before opening the second FileWriter gave me the expected output.
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
public class FileWriterTest {
public static void main(String[] args) {
try{
char[] arr = {'c','a','b','d','e','f'};
File f = new File("C:\\_develop\\Test.txt");
FileWriter fw = new FileWriter(f);
fw.write('f');
fw.write(97);
fw.write("arath",1,3);
fw.write(arr,1,5);
fw.flush(); // Add this line
System.out.println(fw.getEncoding());
FileWriter fw1=new FileWriter(f,true);
fw1.write("vana",1,3);
fw1.flush();
fw1.close();
fw.close();
}
catch(IOException ioe)
{
ioe.printStackTrace();
}
}
}
Hope this help.