以下目录结构的picture.jpg绝对图像路径和相对图像路径是什么?
JavaProject
|_Package1
| |_App1.java
|
|_Package2
|
PICS
|_picture.jpg
public class App1 extends Application{
...
Image picturePath = new Image( ??? );
ImageView picture = new ImageView(picturePath);
...
}
答案 0 :(得分:1)
相对于项目的绝对路径是:
Image picturePath = new Image("/Package2/Picture/picture.jpg");
如果您需要相对于类文件的路径,可以使用:
Image picturePath = new Image("../Package2/Picture/picture.jpg");