阅读更多
package com.hangcheng.util;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import android.app.Activity;import android.content.Context;import android.content.res.AssetManager;public class GetfilesFromAssets {private Activity activity;private String[] files;public GetfilesFromAssets(Context context) {this.activity = (Activity) context;}// public void deepFile(Context ctxDealFile, String path) {// try {// String str[] = ctxDealFile.getAssets().list(path);// if (str.length > 0) {// 如果是目录// File file = new File("/data/" + path);// file.mkdirs();// for (String string : str) {// path = path + "/" + string;// System.out.println("zhoulc:\t" + path);// // textView.setText(textView.getText()+"\t"+path+"\t");// deepFile(ctxDealFile, path);// path = path.substring(0, path.lastIndexOf('/'));// }// } else {// 如果是文件// InputStream is = ctxDealFile.getAssets().open(path);// FileOutputStream fos = new FileOutputStream(new File("/data/"// + path));// byte[] buffer = new byte[1024];// int count = 0;// while (true) {// count++;// int len = is.read(buffer);// if (len == -1) {// break;// }// fos.write(buffer, 0, len);// }// is.close();// fos.close();// }// } catch (IOException e) {// // TODO Auto-generated catch block// e.printStackTrace();// }// }public String[] getfileFromAssets(String path) {AssetManager assetManager = activity.getAssets();// String[] files;try {files = assetManager.list(path);} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}return files;}public List listHtmlOfAssets() {List list = new ArrayList();files = getfileFromAssets("html");for (int i = 0; i < files.length; i++) {HashMap map = new HashMap();map.put("htmlname", files[i]);list.add(map);}return list;}}

更多相关文章

  1. Android——实现清除应用缓存功能
  2. android 反射解析xml文件成为java对象
  3. 获取sdcard文件
  4. 【Android】共享APK中的资源文件
  5. android facebook authorize 时禁止调用facebook app
  6. Android(安卓)本地文件管理类
  7. Android文件读写
  8. Android(安卓)结束进程的方法forceStopPackage
  9. NPM 和webpack 的基础使用

随机推荐

  1. android应用安全——组件通信安全(Intent)
  2. 时间和日期选择器DatePicker和TimePicker
  3. Android桌面小组件:最简例子
  4. 相机的研究
  5. Android(安卓)MPChart—柱状图
  6. Flutter ------- WebView加载网页
  7. Android使用的SQLite数据库
  8. 处理运行时更改
  9. [Android实例] android中进行https连接的
  10. Android(安卓)Studio各类常见错误解决方