Issue
I have a project on my eclipse, one of its methods are reading list of files from a folder. when I run it from eclipse or from an exported jar, its fine and works great.
But I have another project on my netbeans for the GUI of this app where I include the exported jar (which works fine) but when I run or export this project from netbeans, it just can't read non-english filenames, it's converting the filenames to something like this
???????? ???? ??? .mp3
I tried to add -J-Dfile.encoding=UTF-8
to the netbeans.conf
and I also tried to select the encoding in the netbeans project properties but no luck.
here is some code:
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...
}
}
the filter 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;
}
};
my project dependencies:
/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
Solution
If you are on java 7 listFiles
is reported broken on mac OS X - see here and links there. If updating does not fix it you should consider moving to nio - or see here.
I'd ike to see the filter you pass in listFiles(filter);
Answered By - Mr_and_Mrs_D