web工程中,java类中如何获取图片资源的路径?
PHP中文网
PHP中文网 2017-04-18 10:16:54
0
2
308

如图:

我想要在ZXingCode类中,加载下面的image文件夹下的图片,路径怎么写?
File file = new File(filePath);
试着放了几个地方都不知道怎么写,不要本地绝对路径,要项目路径

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
小葫芦
public static void main(String[] args){
    URL url = ClassLoader.getSystemResource("config/image/***.jpg");
    File file = new File(url.getPath());
    System.out.println(file.exists());
}

More references here

PHPzhong

Why do you have to ask questions when you can get the answer from any search engine?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!