R
Robert J. Hansen
I have a Process and a DataInputStream ("dis", in the code below)
hooked up to the Process's getInputStream(). When trying to read from
it, it reads just fine up to the very end. Once there's no more data
to be found, it blocks.
What's particularly vexing is that it's only one user who's having this
problem. For all other users, it's working just fine. The affected
system is XP SP2, if that matters.
I've tried using a BufferedReader and tried it as a plain-Jane
DataInputStream and as a ... etc. Nothing works. Does anyone here
have any ideas about what's happening, or how to get the code to
reliably detect eof?
(Incidentally, I apologize in advance if the following code is
misformatted. Google Groups tends to be code-unfriendly.)
===
StringBuffer output = new StringBuffer();
try {
byte[] buf = new byte[4096];
logNoNewline("Reading... got ");
int bytesRead = dis.read(buf);
while (bytesRead != -1) {
log(bytesRead + " bytes");
output.append(new String(buf, 0, bytesRead));
logNoNewline("Reading... got ");
bytesRead = dis.read(buf);
}
log("eof");
} catch (Exception e) {
log("FIXME: exception caught while dumping key information");
log("FIXME: " + e);
}
===
hooked up to the Process's getInputStream(). When trying to read from
it, it reads just fine up to the very end. Once there's no more data
to be found, it blocks.
What's particularly vexing is that it's only one user who's having this
problem. For all other users, it's working just fine. The affected
system is XP SP2, if that matters.
I've tried using a BufferedReader and tried it as a plain-Jane
DataInputStream and as a ... etc. Nothing works. Does anyone here
have any ideas about what's happening, or how to get the code to
reliably detect eof?
(Incidentally, I apologize in advance if the following code is
misformatted. Google Groups tends to be code-unfriendly.)
===
StringBuffer output = new StringBuffer();
try {
byte[] buf = new byte[4096];
logNoNewline("Reading... got ");
int bytesRead = dis.read(buf);
while (bytesRead != -1) {
log(bytesRead + " bytes");
output.append(new String(buf, 0, bytesRead));
logNoNewline("Reading... got ");
bytesRead = dis.read(buf);
}
log("eof");
} catch (Exception e) {
log("FIXME: exception caught while dumping key information");
log("FIXME: " + e);
}
===