Best way to read text in.

There are so many different streams and I have no idea which one I should use >_< What is the best stream to use for file I/O? BufferedReader and BufferedWriter? Or something else.

EDIT: I’m reading the text from a socket if that makes a difference.

Here is an example for you: http://download.oracle.com/javase/tutorial/networking/sockets/readingWriting.html

What kind of data are you reading? Take for instance the StringReader. It reads Strings from a stream of Chars.
The BufferedReader reads text, also from Chars, but can easier manage arrays and larger text bits that would otherwise be costly.
That’s if you’re reading text.

However, if you’re reading datapackets (Which I almost think, since you’re transferring them over a network), I would use DataInputStream because it provides very low level operations like “readBoolean()”.

@Stranger Thanks I’ll take a look at that tomorrow, it’s a bit late right now

@Mads I’m reading text over a network, and I’m currently using a BufferedReader and BufferedWriter.

Then I guess you should be good :slight_smile: