如何使用 Java getResource() 从父目录获取资源?
我现在已经尝试了许多方法,包括来自commons IO的文件名Utils.normalize(),但我似乎无法在另一个文件夹中获取资源来获取Java FXML文件。
代码如下
try {
root = FXMLLoader.load(getClass().getResource("../plugin/PluginSelection.fxml"));
} catch (IOException ex) {
Logger.getLogger(QueueOperationsController.class.getName()).log(Level.SEVERE, null, ex);
}
其中所需的 FXML 文件是:
gui
dialogues
plugins
PluginSelection.fxml // desired file
dataset
QueueOperationsController // current class
如何最好地获取所需文件的 URL?
谢谢!