java.io.BufferedWriter class is used to write string into a file in java.
With FileWriter, no need to check if File exists and no need to create the file.
The constructor takes the java.io.FileWriter object and creates the new file if the file does not exists.
There are two constructons for FileWriter class
1) FileWriter(file) - Content is over written
2) FileWriter(file, boolean append) - If append is true then content is appended
If boolean append is true, then the content is appended to the file else the content is over written
Its very important to call the flush() and close() method on the BufferedWriter otherwise contents will not be written to the file created.
To write using BufferedWriter following methods can be used :
1) write(String s) - It simply writes the String passed to this method
2) write(String s, int off, int len) - It writes the String from index off till len. If offset > 0 then len must be equal to len - off, otherwise it will throw java.lang.StringIndexOutOfBoundsException: String index out of range: