Here you can find the source of getFiles(File directory)
Parameter | Description |
---|---|
directory | a parameter |
files | a parameter |
public static List<String> getFiles(File directory)
//package com.java2s; /******************************************************************************* * Copyright (c) 2006-2010 eBay Inc. All Rights Reserved. * 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 *******************************************************************************/ import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { /**/* ww w .ja v a2 s . com*/ * Scans a local directory for existing files. * * @param directory * @param files */ public static List<String> getFiles(File directory) { ArrayList<String> files = new ArrayList<String>(); File[] filesInDir = directory.listFiles(); for (int i = 0; i < filesInDir.length; i++) { File file = filesInDir[i]; if (file.isFile()) { files.add(file.getName()); } } return files; } /** * Deletes everything under a directory (including subdirectories) */ public static List<String> getFiles(String dir) { return getFiles(new File(dir)); } }