读取文件的二进制内容

2051次阅读  |  发布于4年以前

读取文件的二进制内容

Use the File readAsBytes() method to read file contents as bytes.

import 'dart:io';

import 'package:crypto/crypto.dart';

main() async {
  var bytes = await new File('file.txt').readAsBytes();
  // Do something with the bytes. For example, convert to base64.
  String base64 = CryptoUtils.bytesToBase64(bytes);
  print(base64);
}

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8