I have a code to read ascii files. I read it using NIO and bytebuffer
This is the line of code that generate the scanner:
scanner = new Scanner(new String(buffer.array()));
I use \\r\\n as a delimiter .
All works fine, except when the buffer readed less bytes of possibles
( the buffer has 4096 bytes and the file 700, for example)
I use the scanner.hasnext and scanner.next and I read all the lines of text of my file, except the last.
The last scanner.next give me a string from last scanner position up to 4096 !
( and there is not a \\r\\n at the end of scanner)
It seems that 'scanner' fails ?
(I cant send the complete code, sorry)
I have made some corrections.
Now I read the exactly bytes :
scanner = new Scanner(new String(buffer.array(),0,bytes_read));
But there is the same roblem :
if scanner has the next scr:
the first scanner.next give "HELLO" and the follow scanner.hasnext() gives me 'true' ?????