Byte[] and java.lang.OutOfMemoryError reading file by bits

后端 未结 4 1433
深忆病人
深忆病人 2020-12-17 03:49

I am trying to write a reader which reads files by bits but I have a problem with large files. I tried to read file with 100 mb and it took over 3 minutes but it worked.

4条回答
  •  被撕碎了的回忆
    2020-12-17 04:31

    You shouldn't open the whole file into memory. You need to create a byte array buffer with a fixed size, then you open your file from chunks of the size you defined.

提交回复
热议问题