Write data with FileOutputStream : FileOutputStream « File Input Output « Java






Write data with FileOutputStream

   


import java.io.FileOutputStream;

class FileOutputStreamDemo {

  public static void main(String args[]) throws Exception {

    FileOutputStream fos = new FileOutputStream(args[0]);

    // Write 12 bytes to the file
    for (int i = 0; i < 12; i++) {
      fos.write(i);
    }

    // Close file output stream
    fos.close();
  }
}

   
    
    
  








Related examples in the same category

1.File IO
2.Copy Bytes between FileInputStream and FileOutputStream
3.Copy byte between FileInputStream and FileOutputStream
4.Write byte array to a file using FileOutputStream
5.Create DataOutputStream from FileOutputStream
6.Write double to a file using DataOutputStream
7.Append output to file using FileOutputStream
8.Create FileOutputStream object from File object
9.Create FileOutputStream object from String file path
10.Write file using FileOutputStream
11.Use FileOutputStream to write the bytes to a file.
12.Write UTF String, integer and double with DataOutputStream
13.Split file
14.Rollover FileOutputStream