Using Java 7 API to read a file byte by byte

后端 未结 2 1759
别跟我提以往
别跟我提以往 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.

    0 讨论(0)
  • 2021-01-16 16:03

    Try Memory Mapped I/O, the last example in this tutorial: http://www.polarsparc.com/pdf/MemoryMappedIOinJava.pdf

    0 讨论(0)
提交回复
热议问题