joseleonweb

Untitled

Feb 27th, 2021
792
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  1. try {
  2.             // read bytes until End Of File is encountered
  3.             do {
  4.                 i = fin.read(); // Read from the file
  5.                 if(i != -1) System.out.print((char) i);
  6.             } while(i != -1); // When i equals -1, the EOF has been reached
  7.         } catch(IOException exc) {
  8.             System.out.println("Error reading file.");
  9.         }
  10.        
  11.         try {
  12.             fin.close(); // Close the file
  13.         } catch(IOException exc) {
  14.             System.out.println("Error closing file.");
  15.         }
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment