-2
即时通讯尝试将具有26个文件(A-Z)的文件夹复制到另一个目录。到目前为止这么好,如果我用我的IDE启动程序,一切都可以正常工作。但如果即时通讯运行导出的jar不起作用。我已经看着这个罐子和我想要复制的文件夹在那里。将文件从资源复制到文件夹
private void copyCharacterFiles() {
for (String s : Utils.ALPHABET) {
try {
File source = new File("resources/characters/" + s.toUpperCase() + ".yml");
File dest = new File(APPLICATION_PATH + PATHSEPARATOR + "characters" + PATHSEPARATOR + s.toUpperCase() + ".yml");
FileChannel sourceChannel = null;
FileChannel destChannel = null;
try {
sourceChannel = new FileInputStream(source).getChannel();
destChannel = new FileOutputStream(dest).getChannel();
destChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
} finally {
sourceChannel.close();
destChannel.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
感谢您的帮助^^
你确定吗,没有像德国ä或ß等特殊字符的文件夹? –
^^长话短说:用'getResourceAsStream'读取文件 – BackSlash