Use the File writeAsBytes() method to write bytes to a file.
import 'dart:io'; import 'dart:convert'; main() async { final string = 'Dart!'; // Encode to UTF8. var encodedData = UTF8.encode(string); var file = await new File('file.txt'); file.writeAsBytes(encodedData); var data = await file.readAsBytes(); // Decode to a string, and print. print(UTF8.decode(data)); // Prints 'Dart!'. }
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did129445