Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get folder from Resources folder JAVA

Tags:

java

file

src

Hi everyone I can't figure out with this problem : this line of code should work

File[] file = (new File(getClass().getResource("resources/images_resultats"))).listFiles();

I want a list of File, these Files are under "images_resultats" under "resources".

Project image

like image 335
Arnauld Alex Avatar asked Apr 14 '16 12:04

Arnauld Alex


1 Answers

It won't work if resources/images_resultats is not in your classpath and/or if it is in a jar file.

Your code is not even correct it should something like:

File[] file = (new File(getClass().getResource("/my/path").toURI())).listFiles();
like image 180
Nicolas Filotto Avatar answered Oct 14 '22 17:10

Nicolas Filotto