I want to read each line from a text file and store them in an ArrayList (each line being one entry in the ArrayList).
So far I understand that a BufferedInputStream writes to the buffer and only does another read once the buffer is empty which minimises or at least reduces the amount of operating system operations.
Am I correct – do I make sense?
If the above is the case in what situations would anyone want to use DataInputStream. And finally which of the two should I be using and why – or does it not matter.
Use a normal
InputStream(e.g.FileInputStream) wrapped in anInputStreamReaderand then wrapped in aBufferedReader– then callreadLineon theBufferedReader.DataInputStreamis good for reading primitives, length-prefixed strings etc.