Java File Name Get getFileNameArrayFromDirectory(String directoryLocation)

Here you can find the source of getFileNameArrayFromDirectory(String directoryLocation)

Description

get File Name Array From Directory

License

Open Source License

Parameter

Parameter Description
directoryLocation Target Directory.

Return

Array of file Name.

Declaration

public static String[] getFileNameArrayFromDirectory(String directoryLocation) 

Method Source Code

//package com.java2s;
/**//ww w.  ja  va  2 s .  c om
 * Copyright (c) {2011} {meter@rbtsb.com} {
 * individual contributors as indicated by the @authors tag}.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Private License v1.0
 * which accompanies this distribution, and is available at
 * http://www.rbtsb.com
 */

import java.io.File;

public class Main {
    /**
     * @param directoryLocation
     *            Target Directory.
     * @return Array of file Name.
     */
    public static String[] getFileNameArrayFromDirectory(String directoryLocation) {
        String[] children = null;
        try {
            File dir = new File(directoryLocation);
            children = dir.list();
            if (children == null) {
                children = new String[0];
            }

        } catch (Exception e) {
            e.printStackTrace();
            children = new String[0];
        }
        return children;
    }
}

Related

  1. getFileName(String s)
  2. getFileName(String s)
  3. getFileName(String template, String className, String packageName)
  4. getFileName(String url, String basePath)
  5. getFileNameAndExt(String s)
  6. getFileNameFilter(final String endsWith)
  7. getFilenameFilter(final String extension)
  8. getFilenameFilter(final String pFilter, final boolean pExclude)
  9. getFilenameForClassName(String className)