Writing file in java

Writing file in java can be done in various ways. We will see some ways along with the code.

Writing File in java using FileOutputStream and BufferedOutputStream

Please Note:

FileOutputStream has another construtor that is
FileOutputStream(File file, boolean append)
If append = true , then the contents that we need to write are appended to the existing contents of the file, else the existing contents are overwritten.

Writing File in java using BufferedWriter

Please Note:

FileWriter has another construtor that is
FileWriter(String fileName, boolean append)
If append = true , then the contents that we need to write are appended to the existing contents of the file, else the existing contents are overwritten.

It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn