Using Java 7 API to read a file byte by byte

后端 未结 2 1779
别跟我提以往
别跟我提以往 2021-01-16 15:05

I have a 2 gb file I want to read in Java (actually four 2gb files). And so there\'s a new feature in Java 7 that can let me read all the bytes at once.

impo         


        
2条回答
  •  温柔的废话
    2021-01-16 15:58

    Reading byte by byte is the other extreme solution, and will be very inefficient. You should simply use a BufferedInputStream, and read the bytes chunk by chunk.

    Read the Java IO tutorial about byte streams.

提交回复
热议问题