Here you can find the source of getFileList(String dir)
Parameter | Description |
---|---|
dir | a parameter |
public static List<String> getFileList(String dir)
//package com.java2s; //License from project: Apache License import java.io.*; import java.util.ArrayList; import java.util.List; public class Main { /**//from w ww. j av a 2s .co m * Get a file list under a directory * * @param dir * @return */ public static List<String> getFileList(String dir) { List<String> fileList = new ArrayList<String>(); File _dir = new File(dir); File[] files = _dir.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { if (files[i].isFile()) { String fileName = files[i].getAbsolutePath(); fileList.add(fileName); } } } return fileList; } /** * Check if it is a valid file * * @param file * @return */ public static boolean isFile(String file) { File f = new File(file); return f.exists() && f.isFile(); } }