[英]JavaFX external directory and resources outside of jar file
我完成此操作的方式如下:
//Make a dir using the users home directory and a filename.
File dir = new File(System.getProperty("user.home") + "/NameOfDir/");
//List the files in that dir
File[] listOfFiles = dir.listFiles();
//If there are no files, do stuff.
if (listOfFiles == null) {
//If the dir doesn't exist already, make it.
if (!dir.exists()) {
dir.mkdir();
}
//Do stuff in the empty dir
} else {
//List the file names in the dir
List<String> fileNamesList = new ArrayList<String>(Arrays.asList(dir.list()));
//Do stuff with the files list.
}
这将确保目录存在,如果不存在,它将进行创建。 然后,您可以随时随地处理目录。
我已经将它用于JavaFX的幻灯片图像和视频。 祝您一切顺利!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.