Answers for "dart read file"

0

dart read file

import 'dart:convert';
import 'dart:io';

void main(List<String> args) async {
  var myFile = File('myFile');
  // asynchronous
  List<String> linesAsync = await myFile.readAsLines();
  // synchronous
  List<String> linesSync = myFile.readAsLinesSync();
  // stream
  Stream<String> linesStream = myFile.openRead()
  									 .transform(utf8.decoder)
                                     .transform(LineSplitter());
}
Posted by: Guest on May-08-2022

Code answers related to "Dart"

Browse Popular Code Answers by Language