Here you can find the source of getFileList(String path, String searchString)
Parameter | Description |
---|---|
path | a parameter |
searchString | a parameter |
public static Vector<File> getFileList(String path, String searchString)
//package com.java2s; /*/* www . j a va 2 s .com*/ * Copyright 2012 the original author or authors. * * 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 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.File; import java.util.Collections; import java.util.Vector; public class Main { /** * Returns the fileList. * * @author nKarakus * @param path * @param searchString * @return Vector<File> */ public static Vector<File> getFileList(String path, String searchString) { Vector<File> fileList = new Vector<File>(); File dir = new File(path); File[] files = dir.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { if (files[i].getName().contains(searchString)) { fileList.add(files[i]); } } Collections.sort(fileList); return fileList; } return null; } }