/**
* 获取指定目录内所有文件路径
* @param dirPath 需要查询的文件目录
* @param _type 查询类型,比如mp3什么的
*/
public static JSONArray getAllFiles(String dirPath, String _type) {
File f = new File(dirPath);
if (!f.exists()) {//判断路径是否存在
return null;
}
File[] files = f.listFiles();
if(files==null){//判断权限
return null;
}
JSONArray fileList = new JSONArray();
for (File _file : files) {//遍历目录
if(_file.isFile() && _file.getName().endsWith(_type)){
String _name=_file.getName();
String filePath = _file.getAbsolutePath();//获取文件路径
String fileName = _file.getName().substring(0,_name.length()-4);//获取文件名
// Log.d("LOGCAT","fileName:"+fileName);
// Log.d("LOGCAT","filePath:"+filePath);
try {
JSONObject _fInfo = new JSONObject();
_fInfo.put("name", fileName);
_fInfo.put("path", filePath);
fileList.put(_fInfo);
}catch (Exception e){
}
} else if(_file.isDirectory()){//查询子目录
getAllFiles(_file.getAbsolutePath(), _type);
} else{
}
}
return fileList;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有