I’m trying to write a serversocket that reads a postscript stream from a printer driver and writes that stream into a file.
I’m reading data in a while loop and trying to close the connection on input.readLine() = null but my problem is that if I use this statement I’ll lose some data.
Also I tried while(true) but my connection is not closing anymore(After all the stream is transmitted it keeps sending null to my file.)
Did you actually write input.readLine() = null in your program or is it correctly written as input.readLine() == null?
Also why are you using line oriented input? Postscript isn’t guaranteed to have line breaks regularly or even end with a line feed. Lots of PostScript files contain binary data. You should treat the data as a stream of bytes and not assume lines.
while(input.readLine() != null) {
read data from the socket
}
Here, every alternate line is lost! You are reading a line to test if it is null or not. When you read again inside the loop, the line read in the conditional statement is already lost.
[QUOTE=ken_yap;2104686]Did you actually write input.readLine() = null in your program or is it correctly written as input.readLine() == null?
Also why are you using line oriented input? Postscript isn’t guaranteed to have line breaks regularly or even end with a line feed. Lots of PostScript files contain binary data. You should treat the data as a stream of bytes and not assume lines.[/QUOTE]