Skip to content
Advertisement

Tag: inputstream

InputStream never gets EOF

Before anything, allow me to show you my client code: once connected to the actual socket, the client sends out some authentication data, but doesn’t recieve any data, now, it waits to recieve data from the server, and when it does, it processes it fine etc, except, when I stop the server (literally shutting down the program), nothing happens, when

The Properties.load would close the InputStream?

I saw this example, and I didn’t see the close() method invoked on the InputStream, so would prop.load() close the stream automatically? Or is there a bug in the example? Answer The Stream is not closed after Properties.load () The above code returns “-1” so the stream is not closed. Otherwise it should have thrown java.io.IOException: Stream Closed

BufferInputStream vs ByteArrayInputStream

Here are three ways to read an entire file into memory before processing it: Approach A: Approach B: Approach C: Why would I prefer one approach over another? Are there any specific use-cases that call for one approach over another? Why not use a fixed-length byte[] instead? Answer Unless you need anything special in terms of capabilities (e.g. random access),

How to read write this in utf-8?

I was getting an error io.MalformedByteSequenceException: Invalid byte 2 of 2-byte UTF-8 sequence The solution is to read and write file in UTF-8. My code is: I’m reading a url and writing it to a file DirectionResponse.xml. Then reading DirectionResponse.xml and writing the same as *ppre_DirecionResponse.xml* for processing. How do I change this so that reading and writing is done

Advertisement