嗨,我坚持以下代码。我想从文件夹中获取文件,但是当我将项目导出到 jar 文件时,它不会起作用吗?
public String getXSDfilenames() {
String filenames= "";
try {
File currDir = new File(".");
String path = currDir.getAbsolutePath();
path = path.substring(0, path.length()-1);
File file = new File(path+"src\\schemaFiles");
String[] files = file.list(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(".xsd");
}
});
if (file.exists()) {
for (int i = 0; i < files.length; i++) {
System.out.println(path+"src\\schemaFiles\\"+files[i]);
filenames = filenames + files[i] + newline;
}
} else {
System.out.println("No schema files founded in default folder!");
}
}
catch (Throwable e1) {
System.out.println(e1);
}
return filenames;
}
}