Here you can find the source of getAllFilesFromDir(File dir)
Parameter | Description |
---|---|
dir | the dir |
public static List<File> getAllFilesFromDir(File dir)
//package com.java2s; /**//from w ww .ja va2s. c om * Copyright (C) 2007 Asterios Raptis * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { /** * Gets the all files from directory. * * @param dir * the dir * @return A list with all files from the given directory. */ public static List<File> getAllFilesFromDir(File dir) { final List<File> foundedFileList = new ArrayList<>(); final File[] children = dir.getAbsoluteFile().listFiles(); if (children == null || children.length < 1) { return foundedFileList; } for (File child : children) { // if the entry is not a directory if (!child.isDirectory()) { // then // entry is a file foundedFileList.add(child.getAbsoluteFile()); } } return foundedFileList; } }