a function that reads X lines from the end of a file. I'm doing that by reading chunks of 4096 bytes and dividing them to lines. When trying to read the last 4096 chars of the (60kb) file using isr.read(bytearr, filesize-4096, 4096); it gives me IndexOutOfBoundsException.
I tried reading from other points but only from 4000 and earlier it stops giving me this error. Any ideas? On Google I only saw people who actually went out of bounds. Nothing like this issue 😓
java.nio.file.Files.readAllLines() outputs a List<String>. Iterate over it backwards. No chunk non-sense
Wouldn't it be really inefficient? It's for an android app, so inefficiency translates to battery drain
How big of a text file are you expecting?
A little bit but not that much, yolo it
See if this works... divide the filesize by 4096 & the remainder will give you the last chunk size. Do the read for the entire file & inside the exception (IndexOutOfBoundsException), just execute the isr.read - only for that last chunk.
Обсуждают сегодня