Java File Name Get getFilenames(String dirctory)

Here you can find the source of getFilenames(String dirctory)

Description

get Filenames

License

Open Source License

Declaration

public static String[] getFilenames(String dirctory) 

Method Source Code


//package com.java2s;

import java.io.File;

public class Main {
    public static String[] getFilenames(String dirctory) {
        File dir = new File(dirctory);
        File[] fileArray = dir.listFiles();
        String[] filenames = new String[fileArray.length];
        for (int i = 0; i < fileArray.length; i++) {
            if (fileArray[i].isDirectory()) {
                filenames[i] = "[" + fileArray[i].getName() + "]";
            } else {
                filenames[i] = fileArray[i].getName();
            }//from w w w . j  a va2 s  .com
        }
        return filenames;
    }
}

Related

  1. getFileNames(File[] files)
  2. getFilenames(File[] files)
  3. getFileNames(final String path, final String regex)
  4. getFileNames(final String pDataDir, final String pFilter)
  5. getFilenames(String dir, FilenameFilter filter)
  6. getFileNames(String directory, String file)
  7. getFileNames(String dirPath)
  8. getFilenames(String filenames)
  9. getFileNames(String path, boolean withFullPath)