import java.io.*; public class BinaryFileDemo { public static void main(String[] args) { FileOutputStream outobject
import java.io.*; public class BinaryFileDemo { public static void main(String[] args) { FileOutputStream outobject = null; FileInputStream inobject = null; String cities = "mumbai\n delhi\n chennai\n mathura\n pune\n"; byte citiesarray[] = cities.getBytes(); try{ outobject = new FileOutputStream("Binaryfile.dat"); outobject.write(citiesarray); outobject.close(); inobject = new FileInputStream("Binaryfile.dat"); int i; while((i=inobject.read())!=-1) { System.out.print((char)i); } inobject.close(); } catch(Exception eobj) { System.out.println(eobj); } } }