java.io.FileOutputStream class is used to write string into a file in java. If the file does not exists at the path provided, FileOutputStream class first creates the new file.
With FileOutputStream, no need to check if File exists and no need to create the file.
The constructor takes the java.io.File object and creates the new file.
There are two constructons for FileWriter class
1) FileOutputStream(file) - Content is over written
2) FileOutputStream(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 close() method on the FileOutputStream otherwise contents will not be written to the file created.
The difference between FileWriter to write into File and FileOutputStream is FileWriter write() method takes String content whereas FileOutputStream write() method takes bytes to write the content to file.
To convert String to bytes, use getBytes() method of String class