<<21天精通JAVA>>一书的源码,边学边做,很快上手,适合JAVA初学者.
源代码在线查看: class.dat
import java.io.*;
public class ReadBytes {
public static void main(String[] arguments) {
try {
FileInputStream file = new
FileInputStream("class.dat");
boolean eof = false;
int count = 0;
while (!eof) {
int input = file.read();
System.out.print(input + " ");
if (input == -1)
eof = true;
else
count++;
}
file.close();
System.out.println("\nBytes read: " + count);
} catch (IOException e) {
System.out.println("Error -- " + e.toString());
}
}
}