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 ...
随机推荐
- Java编程思想之三 操作符
在底层,Java中的数据是通过使用操作符来操作的. 3.2 使用Java操作符 操作符接收一个或多个参数,并生成一个新值. 操作符作用于操作数,生成一个新值.有些操作符可能会改变操作数自身的值,这被称 ...
- MyBatis(六):Mybatis Java API编程实现一对多、一对一
最近工作中用到了mybatis的Java API方式进行开发,顺便也整理下该功能的用法,接下来会针对基本部分进行学习: 1)Java API处理一对多.多对一的用法: 2)增.删.改.查的用法: 3) ...
- com.alibaba.druid.pool.DruidPooledConnection cannot be cast to oracle.jdbc.OracleConnection 异常解决办法
java.lang.ClassCastException: com.alibaba.druid.pool.DruidPooledConnection cannot be cast to oracle. ...
- CentOS7下NFS服务安装及配置固定端口
CentOS7下NFS服务安装及配置 系统环境:CentOS Linux release 7.4.1708 (Core) 3.10.0-693.el7.x86_64 软件版本:nfs-utils-1. ...
- redis创建集群至少需要几个节点?至少需要几个master节点?
描述: 这也算个思考吧,通过redis-trib.rb可创建redis集群,然后通过--replicas后面接的数字,表示1个主节点对应几个从节点,那么我就做了如下的测试,想要达到的效果就是有6个节点 ...
- 【GM4008】GM4008升级固件发布(版本V4.2.1.1)
===================== GM4008固件升级发布 ===================== 〇.简介:GM4008 8通道0-24mA电流采集模块,采用全电气隔离方案,配合高性能 ...
- shell基础知识7-字段分隔符与迭代器
什么是内部字段分隔符 内部字段分隔符(Internal Field Separator,IFS)是shell脚本编程中的一个重要概念.在处理 文本数据时,它的作用可不小. 作为分隔符,IFS有其特殊用 ...
- [No000019A]IDEA 设置手册
[No000019A]idea设置手册.rar IDEA 设置手册 IDEA 设置手册 plugin lgnore files and folesrs 代码管控 程序框架 部署方式 useless 3 ...
- Springboot中IDE支持两种打包方式,即jar包和war包
Springboot中IDE支持两种打包方式,即jar包和war包 打包之前修改pom.xml中的packaging节点,改为jar或者war 在项目的根目录执行maven 命令clean pa ...
- [转]casperjs截图出现黑色背景
原文地址:https://my.oschina.net/tuxpy/blog/879509?utm_medium=referral 如果默认没有指定 body的background-color就会出现 ...