android assets/raw 大文件读取
来源:互联网 发布:sql截取日期的年月日 编辑:程序博客网 时间:2024/06/04 18:06
ref to http://stackoverflow.com/questions/2860157/load-files-bigger-than-1m-from-assets-folder
android read/copy big size file in asset/raw:
1.change filename's sufix to mp3 to prevent the compress for the file.
2.For some file, if zip can save much size, zip it first then using "ZipInputStream" to read it.
InputStream dbIn = getAssets().open("my.zip");
ZipInputStream zis = new ZipInputStream(dbIn);
this have the limit that most time, the zipped file still too large.
3.split the files into multi small blocks and read/write them into one. Many split tools like hjsplit.
FileOutputStream dbOut = new FileOutputStream(dbFile.getAbsolutePath());
for (int i = 1; i < 11; i++) {
// source file open
String fn = String.format("resource.irf.d", i);
InputStream dbIn = getAssets().open(fn);
copyFile(dbIn, dbOut);
dbIn.close();
}
dbOut.close();
helpers to copy file:
private void copyFile(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[1024];
int read;
while ((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
}
private void copyFile(ZipInputStream zis, OutputStream out)throws IOException {
ZipEntry ze = null;
while ((ze = zis.getNextEntry()) != null) {
byte[] buffer = new byte[1024];
int count;
while ((count = zis.read(buffer)) != -1) {
out.write(buffer, 0, count);
}
}
}
android read/copy big size file in asset/raw:
1.change filename's sufix to mp3 to prevent the compress for the file.
2.For some file, if zip can save much size, zip it first then using "ZipInputStream" to read it.
3.split the files into multi small blocks and read/write them into one. Many split tools like hjsplit.
helpers to copy file:
0 0
- android assets/raw 大文件读取
- android 文件读取(assets,raw)
- android 文件读取(assets、raw)
- Android 的assets文件资源与raw文件资源读取
- Android从assets和raw中读取txt文件
- android原始资源raw和assets文件读取
- Android从assets和raw中读取txt文件
- Android 从assets和raw中读取文件
- android 读取assets下和raw下的txt文件
- res/raw和assets 文件读取
- Android 获取assets文件和raw文件
- android assets 文件读取
- android文件读取assets
- Android学习笔记(三)——读取raw文件和assets文件
- android 基础 res文件 assets xml raw
- Android资源文件目录assets和raw
- Android中assets目录和raw目录的区别及其中properties资源文件的读取
- Android res/raw文件以及raw与res/assets异同
- Android中使用WebView, WebChromeClient和WebViewClient加载网页
- POJ 2533 Longest Ordered Subsequence
- 优化网站加载速度的14个技巧
- 用NAT实现外网对内网服务器的访问
- Shadow DOM 与 HTML Templates
- android assets/raw 大文件读取
- 环形缓冲区
- postgres插入默认值 如果select查询不到默认值
- 声道
- orale数据类型对应java类型
- OpenCV学习--saturate_cast防止数据溢出
- java.sql.Clob转String
- SDI应用程序调用DestroyWindow()退出程序出现异常引起的一些思考
- OpenCV中图像旋转(warpAffine)算法的实现过程