3 Replies Latest reply on Jul 28, 2010 11:59 PM by EJP

    Scanner fails with String obtained from bytebuffer ?

      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 ?
      Any idea?

      (I cant send the complete code, sorry)