question archive How do we input a bin file in java?
Subject:Computer SciencePrice:2.86 Bought3
How do we input a bin file in java?

to read or write binary files in java you can use BufferedInputStream and BufferedOutputStream functions.Though you will also need to FileInputStream and FileOutputStream functions.
A basic example is below
to read the file:-
FileInputStream fi = new FileInputStream(new File("(File name here)"));
BufferedInputStream reader = new BufferedInputStream(fi);
int ch;
while ((ch = reader.read()) != -1) {
System.out.print((char) ch);
reader.close
to write the file
FileOutputStream fo = new FileOutputStream(new File("(File name here)"));
BufferedOutputStream writer = new BufferedOutputStream(fo);
writer.write("Hey!".getBytes());
writer.write("\n".getBytes());
writer.write("How are you?".getBytes());
writer.flush();
writer.close();
In ove cases you need to put your File name of the file you want to read or write instead of(File name here)

