Issue I faced in File.openRead() from dart:io

71 views
Skip to first unread message

Anjan Roy

unread,
Aug 21, 2019, 8:06:53 PM8/21/19
to Dart Core Development
Last day I was using File.openRead() method from dart:io for reading a ASCII text file as stream, from a certain start position to end position.

Dart Code was like :

import 'dart:io';
import 'dart:convert' show utf8;

main() {
 File('./test.txt').openRead(0, 9).transform(utf8.decoder).listen(
       (elem) => print(elem),
     );
}


ASCII Text file I was reading as stream :

This is just a test file.

Result I got in console :

Screenshot from 2019-08-12 11-36-25.png


As File.openRead() 's doc at https://api.dart.dev/stable/2.4.1/dart-io/File/openRead.html showing, it was expected to read upto byte index 9 from index 0 ( applicable for this case ), though it read upto byte index 8 .

I expected it to give me a output like below

This is ju

If I'm making a mistake, would you mind putting me in correct path ?

Thanks :)

Stan Manilov

unread,
Aug 22, 2019, 4:12:01 AM8/22/19
to Dart Core Development
Hi Anjan,

It seems that "up-to" here means "up-to but excluding", as usual.

Cheers,
 - Stan
Reply all
Reply to author
Forward
0 new messages