//Files.java //demo file I/Os //File of bytes: "low-level" I/O //File of primitve data types: "high-level" I/O //File of text import java.io.*; public class Files { public static void main( String[] args ) { File myFile; File myFolder; int status; //File of bytes. Low-level file I/O File outFile = new File( "sampleByte.data" ); FileOutputStream outStream; //example data: byte[] B = {20,40,50,60,70,80,90,100, 65,66,67}; //open the file: try { outStream = new FileOutputStream( outFile ); outStream.write( B ); //the whole array outStream.write( B[8] ); //one byte 65='A' outStream.close(); } catch (IOException e) { System.out.println( "threw an exception...deal with it..." ); } //viewing the sampleByte.data file will look like various ASCII characters. //the bytes are interpretted as such by the viewer program. System.out.println("look at the sampleByte.data file"); //turn around and read in the data File inFile = new File( "sampleByte.data" ); FileInputStream inStream; //open the file: try { //inStream = new FileInputStream( inFile ); inStream = new FileInputStream( "sampleByte.data" ); //bypass File object int filesize = (int) inFile.length(); //size of file byte [] C = new byte[filesize]; //another array of bytes inStream.read( C ); //the whole file into the array inStream.close(); //display the inputted data. as converted to strings System.out.println("Here's the byte data read in from the file:"); for (int i=0; i