Should I use DataInputStream or BufferedInputStream

前端 未结 7 935
南方客
南方客 2020-12-13 20:55

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

7条回答
  •  一整个雨季
    2020-12-13 21:38

    Use a normal InputStream (e.g. FileInputStream) wrapped in an InputStreamReader and then wrapped in a BufferedReader - then call readLine on the BufferedReader.

    DataInputStream is good for reading primitives, length-prefixed strings etc.

提交回复
热议问题