Here you can find the source of getFilenames(String dirctory)
public static String[] getFilenames(String dirctory)
//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; } }