Program in java to create file in byte mode


import java.io.*;

class ByteModeFile {

public static void main (String[] args)  throws Exception
{
        System.out.println("Enter the name of file");
             DataInputStream c=new DataInputStream(System.in);
             String name=c.readLine();
    FileOutputStream fout =new FileOutputStream(name);
String n=" ";
StringBuffer sb=new StringBuffer(1024);
try {
        while(n!=null)
        {
        n=c.readLine();
        sb.append(n);
    }
}
catch (Exception ex) {
    System.err.println("Error "  );
    ex.printStackTrace();
}
finally
{
    fout.write(new String(sb).getBytes());
    fout.close();
}
}


}

Comments