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(安卓)解决Could not find com.android.tools.build:grad
  2. android播放音乐文件代码
  3. Android得到SD卡文件夹大小以及删除文件夹操作
  4. Android(安卓)ndk开发之在c文件里打印log
  5. Android中常用的函数
  6. Android实现振动效果
  7. 通用android studio gradle 文件(电商商家版,两个gradle不同)
  8. android 学习心得
  9. NPM 和webpack 的基础使用

随机推荐

  1. Android:ActivityOptions
  2. 用TextView自定义按钮
  3. android p cts CtsCameraTestCases fail
  4. Android emulator
  5. js检测手机类型(android,ios,blackberry,w
  6. Android:圆形CheckBox
  7. Android WebView嵌套Html 之一
  8. android ant使用分析
  9. 【Android多媒体】多媒体架构-Android官
  10. Airbnb Android