我的 Eclipse 上有一个项目,其中一种方法是从文件夹中读取文件列表。当我从 Eclipse 或从导出的 jar 运行它时,它很好并且效果很好。
但是我的 netbeans 上有另一个项目,用于这个应用程序的 GUI,其中包含导出的 jar(工作正常)但是当我从 netbeans 运行或导出这个项目时,它只是无法读取非英语文件名,它正在转换像这样的文件名
???????? ???? ??? .mp3
我尝试添加-J-Dfile.encoding=UTF-8
,netbeans.conf
并且还尝试在 netbeans 项目属性中选择编码,但没有运气。
这是一些代码:
public SFile(String path, FileFilter filter) {
File f = null;
f = new File(path);
directory = f.isDirectory();
if (directory) {
children = new ArrayList<SFile>();
File[] ki = f.listFiles(filter); // here i see the ???? ????.mp3
ArrayList<File> kids = new ArrayList<File>();
Collections.addAll(kids, ki);
Collections.sort(kids, comparator);
for (File k : kids) {
if (k.isDirectory() && k.listFiles(filter).length == 0) {
continue;
}
children.add(new SFile(k.getAbsolutePath(), filter));
}
} else {
// some more code...
}
}
过滤器代码:
new FileFilter() {
public boolean accept(final File pathname) {
try {
return pathname.getCanonicalPath().endsWith(".mp3") || pathname.isDirectory();
} catch (final IOException e) {
e.printStackTrace();
}
return false;
}
};
我的项目依赖项:
/Users/dima/Dev/RSLib/asm-3.1.jar
/Users/dima/Dev/RSLib/grizzly-framework-2.2.16.jar
/Users/dima/Dev/RSLib/grizzly-http-2.2.16.jar
/Users/dima/Dev/RSLib/grizzly-http-server-2.2.16.jar
/Users/dima/Dev/RSLib/grizzly-rcm-2.2.16.jar
/Users/dima/Dev/RSLib/gson-2.2.2.jar
/Users/dima/Dev/RSLib/javax.servlet-api-3.1-b05.jar
/Users/dima/Dev/RSLib/jersey-bundle-1.16.jar
/Users/dima/Dev/RSLib/jersey-core-1.16.jar
/Users/dima/Dev/RSLib/jersey-grizzly2-1.16.jar
/Users/dima/Dev/RSLib/jersey-server-1.16.jar
/Users/dima/Dev/RSLib/jsr311-api-1.1.1.jar
/Users/dima/Dev/RSLib/log4j-1.2.17.jar
/Users/dima/Dev/RSLib/jid3lib-0.5.4.jar
/Users/dima/Dev/RSLib/cling-distribution-2.0-alpha2/cling-mediarenderer-2.0-alpha2-standalone.jar
/Users/dima/Dev/RSLib/cling-distribution-2.0-alpha2/cling-workbench-2.0-alpha2-standalone.jar
/Users/dima/Dev/RSLib/cling-distribution-2.0-alpha2/core/seamless-http-1.0-alpha2.jar
/Users/dima/Dev/RSLib/cling-distribution-2.0-alpha2/core/seamless-util-1.0-alpha2.jar
/Users/dima/Dev/RSLib/cling-distribution-2.0-alpha2/core/seamless-xml-1.0-alpha2.jar
/Users/dima/Dev/RSLib/cling-distribution-2.0-alpha2/support/cling-support-2.0-alpha2.jar
/Users/dima/Dev/RSLib/cling-distribution-2.0-alpha2/core/cling-core-2.0-alpha2.jar
/Users/dima/Dev/RSLib/MpegAudioSPI1.9.5/mp3spi1.9.5.jar
/Users/dima/Dev/RSLib/MpegAudioSPI1.9.5/lib/jl1.0.1.jar
/Users/dima/Dev/RSLib/MpegAudioSPI1.9.5/lib/tritonus_share.jar