需求:
读取 linux 项目上的文件结构显示出来
问题:
java 项目部署在 linux 平台上,读取 linux 上的文件目录,但是当遇到中文目录的时候,就无法读取到了,英文的可以,这个是什么原因?
我搜了很多,都说是编码问题,但是转了编码,貌似还是不行?搞了大半天都不行,各位大佬帮帮忙
代码如下
String sysRunPath = GCONST.getRootPath();
String filePath = sysRunPath + "ClifePage" + File.separatorChar + "train" + File.separatorChar + "OATrainingCourse";//读取父目录
// File file = new File( new String(filePath.getBytes("gbk"), "utf-8")); 转码了但是还是有问题
File file = new File(filePath);
JSONArray ja = new JSONArray();
JSONArray jc = new JSONArray();
try {
showFile(file, ja);//列出父目录下面的子目录
jc = ja.getJSONObject(0).getJSONArray("children");
} catch (JSONException e) {
e.printStackTrace();
}