file I/O question
From: slurper (slurper1234_at_skynet.be)
Date: 03/22/05
- Previous message: proGex: "Re: reference books"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 22 Mar 2005 20:36:06 +0100
try {
FileInputStream fis = new FileInputStream("README.TXT");
int n;
while ((n = fis.available()) > 0) {
byte[] b = new byte[n];
int result = fis.read(b);
if (result == -1) break;
String s = new String(b);
System.out.print(s); }
// End while
}
// End try catch (IOException e) {System.err.println(e);}
System.out.println();
i wonder if this code snippet is correct. I think it is possible that not
all content of README.TXT will be printed.
the loop will run as long as there are bytes available without blocking the
program. but will there be bytes available after opening the file? the
program needs to block immediately waiting for I/O, or do i see this wrong?
tx
- Previous message: proGex: "Re: reference books"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|