Here you can find the source of getFilesFromFolder(String folderPath, boolean withAbsolPath)
public static List<String> getFilesFromFolder(String folderPath, boolean withAbsolPath)
//package com.java2s; /*/*from ww w .jav a 2s . co m*/ * Copyright 2010 * IBB-CEB - Institute for Biotechnology and Bioengineering - Centre of Biological Engineering * CCTC - Computer Science and Technology Center * * University of Minho * * This is free software: you can redistribute it and/or modify * it under the terms of the GNU Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Public License for more details. * * You should have received a copy of the GNU Public License * along with this code. If not, see http://www.gnu.org/licenses/ * * Created inside the SysBioPseg Research Group (http://sysbio.di.uminho.pt) */ import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { public static List<String> getFilesFromFolder(String folderPath, boolean withAbsolPath) { File folder = new File(folderPath); List<String> toRet = new ArrayList<>(); String[] allFiles = folder.list(); if (withAbsolPath) { for (String file : allFiles) { toRet.add(folderPath + File.separator + file); } } else toRet = Arrays.asList(allFiles); return toRet; } }