copy file
import io,,,,,,,
from https://pub.dev/packages/large_file_copy
Directory directory = await getApplicationDocumentsDirectory();
var dbPath = join(directory.path, "app.db");
if (FileSystemEntity.typeSync(dbPath) == FileSystemEntityType.notFound) {
ByteData data = await rootBundle.load("assets/my_db_file.db");
List<int> bytes = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
await File(dbPath).writeAsBytes(bytes);
}
var file1 = File(join(tempDir.path, '0/2048.apk'));
var newFile = await file1.copy(join(tempDir.path, '4/1.apk'));
import 'package:flutter/material.dart';
import 'dart:io';
import 'dart:async';
import 'package:rxdart/rxdart.dart';
import 'package:path_provider/path_provider.dart';
import 'package:path/path.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:flutter/services.dart'; void main() => runApp(MaterialApp(home: MyApp(),)); /*
1. Copy aria2c executable to ``/mnt/sdcard`` on your device.
2. Run Android Terminal Emulator.
3. ``mkdir /data/data/jackpal.androidterm/aria2``
4. ``cat /mnt/sdcard/aria2c > /data/data/jackpal.androidterm/aria2/aria2c``
5. ``chmod 744 /data/data/jackpal.androidterm/aria2/aria2c``
6. Add the following commands to the initial command of Android
Terminal Emulator:: export HOME=/data/data/jackpal.androidterm/aria2; cd $HOME 7. Exit Android Terminal Emulator.
8. Run Android Terminal Emulator again.
9. See whether aria2c actually works by invoking ``./aria2c -v``
*/ class MyApp extends StatelessWidget {
DataBloc bloc; checkPermission()async{
var per = await PermissionHandler().checkPermissionStatus(PermissionGroup.storage);
if(per!=PermissionStatus.granted){
await PermissionHandler().requestPermissions([PermissionGroup.storage]);
}
} cp()async{
await checkPermission();
Directory tempDir = await getExternalStorageDirectory();
String workDir = join(tempDir.path, '4'); // var p = await Process.run('mkdir', [workDir]).then((ProcessResult e){
// print(e.stderr);
// print(e.exitCode);
// }); var file1 = await rootBundle.load('assets/aria2c');
var buf = file1.buffer;
File(join(workDir, 'xxx')).writeAsBytesSync(buf.asUint8List());
// var newFile = await file1.copy(join(tempDir.path, '4/1.apk'));
print('done');
} @override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('sss'),),
body: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
RaisedButton(child: Text('mkdir'),onPressed: (){
cp();
},),
RaisedButton(child: Text('delete'),onPressed: (){ },),
Container(
width: 50,height: 50,child: Image(image: AssetImage('assets/img/a.png',),fit: BoxFit.cover,)),
// Container(
// width: 50, height: 50,child: Text(' '),decoration: BoxDecoration(
// image: DecorationImage(image: AssetImage('assets/img/a.png')),
// ),),
],
),
),
);
}
} class DataBloc {
ReplaySubject dataBloc = ReplaySubject();
} //void shell(String cmd, List<String> opts, void onExit(int exitCode))async{
// var p = await Process.start(cmd, opts);
// p.stdout.pipe(stdout);
// stdin.pipe(p.stdin);
// p.onExit = (exitCode)async{
// await p.kill();
// onExit(exitCode);
// }
//} //void shell(String cmd, List<String> opts, void onExit(int exitCode)) {
// var p = Process.start(cmd, opts);
// p.stdout.pipe(stdout); // Process output to stdout.
// stdin.pipe(p.stdin); // stdin to process input.
// p.onExit = (exitCode) {
// p.close();
// onExit(exitCode);
// };
//}
copy file的更多相关文章
- 解决编译报错:Unable to copy file, because it is being used by another process.
Error 63 Unable to copy file "D:\DEV\XXX Website\trunk\4 Source Code\Common\WebControls\b ...
- VS2008 解决Unable to copy file 对路径的访问被拒绝。
在VS2008 + WINDOWS 7 环境下重新生成解决方案时遇到以下问题 Unable to delete file "F:\XX.exe". 对路径"F:\XX.e ...
- Unable to copy file, Access to the path is denied
Unable to copy file, Access to the path is denied http://stackoverflow.com/questions/7130136/unable- ...
- ansible copy file
ansible xxxip -m copy -a 'src=/localdir/file dest=/sss/xxx/basic_search/bin/'
- ant copy file
<project name="selftask" default="docopy" basedir="."> <descr ...
- copy file using FileReader/Writer.
The code below demonstates copying file using 'FileReader' and 'FileWriter'. class CopyV2 extends Ti ...
- [每天解决一问题系列 - 0002] Xcopy cannot copy file with long directory
现象: 当xcopy的文件的全名(包括目录和文件名)的长度超过255字符时,会copy失败,得到insufficient memory错误 解决方法: 在Server 版的OS中,有robcopy命令 ...
- copy file to docker from realhost
http://blog.e3rp4y.me/blog/2014/05/23/copy-file-from-host-to-docker.html --------------------------- ...
- copy file to docker、
Docker是个Linux Container管理软件. 今天我们来讲解一下从主机复制文件到Docker的几种方法. 在分享之前, 我们看看Docker社区对这个问题的需求是有多么强(ju)烈(jin ...
随机推荐
- js正则判断字符串中是否包含特殊字符和空格
字符串只能是数字.字母和中文组成,不能包含特殊符号和空格. /^[\u4e00-\u9fa5_a-zA-Z0-9]+$/
- tinylib
tinylib.h /* -------------------------------------------------------------------------------- oooo ` ...
- SpringBoot(十四):SpringCloud初步认识
SpringCloud是一个基于SpringBoot实现的云应用开发工具,它为开发人员提供了一些工具来快速构建分布式系统中的一些常见模式(例如配置管理.服务发现.断路器.智能路由.微代理.控制总线.一 ...
- Invalid bound statement (not found) 终极解决办法
网上已经有很多文章说明可能导致这个报错的原因,无非是以下几种:1.检查xml文件的namespace是否正确 2.Mapper.java的方法在Mapper.xml中没有,然后执行Mapper的方法会 ...
- windows 安装 Composer 报错
错误信息如下: 解决方法: 在 extension = php_snmp.dll 前加上 ";" 然后重启 php 即可安装
- scrapy爬虫案例:问政平台
问政平台 http://wz.sun0769.com/index.php/question/questionType?type=4 爬取投诉帖子的编号.帖子的url.帖子的标题,和帖子里的内容. it ...
- linux默认的2.7升级到3.7版本
CentOS7中自带的python版本是python-2.7.5,由于新开的虚拟机需要使用python3,于是便升级一下版本. 安装Python3.7.3 官网下载地址:https://www.pyt ...
- XT交易所Websocket API
WebSocketAPI xt为用户提供了一个简单的而又强大的API,旨在帮助用户快速高效的将xt交易功能整合到自己应用当中. WebSocket服务地址 xt WebSocket服务连接地址:wss ...
- linux用户态和内核态理解
1.特权级 Intel x86架构的cpu一共有0-4四个特权级,0级最高,3级最低,硬件上在执行每条指令时都会对指令所具有的特权级做相应的检查.硬件已经提供了一套特权级使用的相关机制 ...
- activiti学习6:启动流程后动态获取流程图
目录 activiti学习6:启动流程后动态获取流程图 一.绘图原理 二.根据流程定义id绘图 三.根据流程实例id绘图 3.1 基本原理 3.2 当前节点的获取 3.3 走过的节点的获取 3.4 绘 ...