Java Folder Read getFilesStartingWith(File parentDir, String prefix)

Here you can find the source of getFilesStartingWith(File parentDir, String prefix)

Description

get Files Starting With

License

Open Source License

Declaration

public static HashSet<String> getFilesStartingWith(File parentDir, String prefix) 

Method Source Code

//package com.java2s;
/**//from  w  w  w  .j av a2 s.c  o m
 * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Eclipse Public License (EPL).
 * Please see the license.txt included with this distribution for details.
 * Any modifications to this file must keep this entire header intact.
 */

import java.io.File;

import java.util.HashSet;

public class Main {
    public static HashSet<String> getFilesStartingWith(File parentDir, String prefix) {
        String[] list = parentDir.list();
        HashSet<String> hashSet = new HashSet<String>();
        if (list != null) {
            for (String string : list) {
                if (string.startsWith(prefix)) {
                    hashSet.add(string);
                }
            }
        }
        return hashSet;
    }
}

Related

  1. getFilesModDate(String path)
  2. getFilesOf(File dir)
  3. getFilesOfDirectory(File directory)
  4. getFilesOfTypeInDirectory(File directory, String filetype)
  5. getFilesRegex(final File root, final String[] regex)
  6. getFilesStartingWith(String dirName, String startsWith)
  7. getFileStatus(File file)
  8. getFileString(File file)
  9. getFileString(String filePath)