Write file using FileOutputStream - Java File Path IO

Java examples for File Path IO:FileOutputStream

Description

Write file using FileOutputStream

Demo Code


import java.io.*;
 
public class Main {
 
  public static void main(String[] args) {
   //from w  w  w .  ja v a2  s  .  co  m
     String strFilePath = "C://Folder//demo.txt";
   
     try
     {
      FileOutputStream fos = new FileOutputStream(strFilePath);
      byte b = 01;
     
       fos.write(b);
     
       fos.close();
     }catch(FileNotFoundException ex){
      System.out.println("FileNotFoundException : " + ex);
     }
     catch(IOException ioe)
     {
      System.out.println("IOException : " + ioe);
     }   
  }
}

Related Tutorials