IndexController.java 文件源码

java
阅读 42 收藏 0 点赞 0 评论 0

项目:kbase-doc 作者:
/**
 * 文件列表
 * @author eko.zhan at 2017年8月9日 下午8:32:19
 * @return
 * @throws FileNotFoundException
 */
@ApiOperation(value="获取文件数据列表", notes="获取固定路径下的文件,并返回文件名,文件所在路径和文件大小")
@RequestMapping(value="getDataList", method=RequestMethod.POST)
public JSONArray getDataList() throws FileNotFoundException{
    JSONArray arr = new JSONArray();
    File dir = ResourceUtils.getFile("classpath:static/DATAS");
    File[] files = dir.listFiles();
    for (File file : files){
        if (file.isFile()){
            JSONObject json = new JSONObject();
            json.put("path", file.getPath());
            json.put("name", file.getName());
            json.put("size", file.length());
            arr.add(json);
        }
    }
    return arr;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号