SHARE
TWEET

Untitled

a guest Jun 19th, 2017 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.     public void readFile(String fileName) {
  3.         FileInputStream fileIS;
  4.         BufferedInputStream bufferedIS;
  5.         DataInputStream dataIS;
  6.  
  7.         try {  
  8.             fileIS = new FileInputStream(fileName);
  9.             bufferedIS = new BufferedInputStream(fileIS);
  10.             dataIS = new DataInputStream(bufferedIS);
  11.             System.out.println("Reading file: " + fileName);
  12.             try {
  13.                 while(true) {
  14.                     /*
  15.                      * reads one input byte, zero-extends it to type int, and
  16.                      * returns the result, which is therefore in the range 0
  17.                      * through 255.
  18.                      */
  19.                    
  20.                     int mbyte = dataIS.readUnsignedByte();
  21.                 }
  22.             }
  23.             catch (EOFException eof) {
  24.                 System.out.println( "Finished reading file" );
  25.             }
  26.             dataIS.close();
  27.         }
  28.         catch (FileNotFoundException e) {
  29.             System.out.println("Error: File not found");
  30.         }
  31.         catch (IOException e) {
  32.             System.out.println("IO error: " + e );
  33.         }
  34.     }
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top