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 ...
随机推荐
- JavaScript初探系列(十)——Event
一.绑定事件的两种方式 (一).方式一:onclick 举例: <body> <button>点我</button> <script> var btn ...
- yum -y install pip No package pip available. Error: Nothing to do
centos下安装pip时失败: [root@wfm ~]# yum -y install pipLoaded plugins: fastestmirror, refresh-packagekit, ...
- Git Bash 克隆project
cd 到想要的路径,然后执行下面的命令
- 【基础】Qt SCXML Calculator QML Example
Qt SCXML Calculator QML Example 这个系统自带的例子原本主要是用来说明SCXML机制的,但是由于计算器的经典和简洁,我认为用来练习QML非常合适,原本的例子还有一些问题, ...
- 图片放大神器: waifu2x
在线版可以在这个地址上使用:http://waifu2x.udp.jp/index.zh-CN.html , 但是在线版最大图片为5M,最大上传分辨率为1500*1500,且最大放大倍数为2倍,还是有 ...
- Oracle系列十五 控制用户权限
权限 数据库安全性 --系统安全性 --数据安全性 系统权限: 对于数据库的权限 对象权限: 操作数据库对象的权限 系统权限 超过一百多种有效的权限 数据库管理员具有高级权限以完成管理任务,例如: 创 ...
- C# selenium 高级
https://www.cnblogs.com/morang/p/7441091.html https://www.cnblogs.com/tobecrazy/p/4817946.html https ...
- Java13新特性 -- switch表达式
引入了yield语句,用于返回值: 和return的区别在于:return会直接跳出当前循环或者方法,而yield只会跳出当前switch块. @Test public void testSwitch ...
- Java读取CSV数据并写入txt文件
读取CSV数据并写入txt文件 package com.vfsd; import java.io.BufferedWriter; import java.io.File; import java.io ...
- c++ 二进制方式读取文件 读取特殊类型数据
#include <iostream> #include <fstream> using namespace std; /* 二进制方式进行读写文件,可以读写 各种各样数据类型 ...