Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement