Java Tutorial

 
 
 
 
import java.io.*;

class  WritingBytes
{
    public static void main(String[] args) 
    {
          //Declare and initialize  a byte array
          byte cities[] = {(byte)\'D\',(byte)\'E\',(byte)\'L\',(byte)\'H\',(byte)\'I\',(byte)\'\\n\',
            (byte)\'M\',(byte)\'A\',(byte)\'D\',(byte)\'R\',(byte)\'A\',(byte)\'S\',(byte)\'\\n\',
            (byte)\'L\',(byte)\'O\',(byte)\'N\',(byte)\'D\',(byte)\'O\',(byte)\'N\',(byte)\'\\n\'};

          //Create an output file stream
          FileOutputStream fos =null;
          try{
                fos= new FileOutputStream(\"city.txt\");
                fos.write(cities);
                fos.close();
            }catch(IOException e){}

    }
}

 
 
Didn't find what you were looking for? Find more on Program of writing Bytes to a File