home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-12-14 | 978 b | 38 lines |
- import java.io.*;
-
- public class BufferedReadStream
- {
- // This program runs as an application
- public static void main(String[] arguments)
- {
- try
- {
- //declare a stream
- FileInputStream ifile = new FileInputStream("bufBytes.dat");
- BufferedInputStream bufStream = new BufferedInputStream(ifile);
- boolean eof = false;
- int cntBytes = 0;
- while (!eof)
- {
- int thisVal = bufStream.read();
- System.out.print( thisVal + " ");
- if (thisVal == -1)
- eof = true;
- else
- cntBytes++;
- } //while
- bufStream.close();
- System.out.print("\nBytes read: " + cntBytes);
-
- } catch (IOException e)// handle any errors
- {
- System.out.println("Error - " + e.toString());
- }//catch
- }//main
- }//BufferedReadStream
-
-
-
-
-
-