Ralfi Ralfi - 7 months ago 57
Java Question

How to get files from a project folder

The folder is

. I need to get all file names(
files) from
folder and all subfolders.I dont know the full path to the folder so i need only to focus the project resourse. I need them in array. Using Java8 and Eclipse Mars.
So far this works:

try {

Files.walk(Paths.get("/home/fixxxer/NetBeansProjects/Installer/src/img/")).forEach(filePath -> {
if (Files.isRegularFile(filePath)) {
} catch (IOException ex) {
Logger.getLogger(InstallFrame.class.getName()).log(Level.SEVERE, null, ex);

The problem is that the folder need to be called like this:
cause it is inside the project
Thanks in advance :)


You can use relative paths. Here, I am assuming that Installer is your project name. Otherwise, you can edit the relative path according to your project setup.

Files.walk(Paths.get(".//src//img//")).forEach(filePath -> {
                if (Files.isRegularFile(filePath)) {