Here you can find the source of getFilesWithExtension(File aDirectory, final String aExtension)
Parameter | Description |
---|---|
aDirectory | The directory to search through. |
aExtension | The extention to search with. |
public static File[] getFilesWithExtension(File aDirectory, final String aExtension)
//package com.java2s; /*//from w w w . ja va 2 s . c om * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: * */ import java.io.File; import java.io.FileFilter; public class Main { /** * Returns a list of files from a directory ending with a specific extension. * * @param aDirectory The directory to search through. * @param aExtension The extention to search with. * @return The array of files with a specific extension. */ public static File[] getFilesWithExtension(File aDirectory, final String aExtension) { return aDirectory.listFiles(new FileFilter() { public boolean accept(File lFile) { if (lFile.getName().endsWith(aExtension)) { return true; } return false; } }); } }