Skip to content

Commit b53bc0e

Browse files
committed
Now really delete getFilesFromExtension.
Use one of the listFiles() (and optionally FileFilterUtils.makeCVSAware) instead git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/io/trunk@140409 13f79535-47bb-0310-9956-ffa450edef68
1 parent 07b8e33 commit b53bc0e

1 file changed

Lines changed: 1 addition & 108 deletions

File tree

src/java/org/apache/commons/io/FileUtils.java

Lines changed: 1 addition & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
import java.io.FileFilter;
6363
import java.io.OutputStream;
6464
import java.net.URL;
65-
import java.util.ArrayList;
6665
import java.util.Collection;
6766
import java.util.Date;
6867

@@ -117,7 +116,7 @@
117116
* @author <a href="mailto:jefft@apache.org">Jeff Turner</a>
118117
* @author Matthew Hawthorne
119118
* @author <a href="mailto:jeremias@apache.org">Jeremias Maerki</a>
120-
* @version $Id: FileUtils.java,v 1.17 2003/11/22 20:44:48 jeremias Exp $
119+
* @version $Id: FileUtils.java,v 1.18 2003/11/22 20:51:28 jeremias Exp $
121120
*/
122121
public class FileUtils {
123122

@@ -861,112 +860,6 @@ public static void fileDelete(String fileName) {
861860
file.delete();
862861
}
863862

864-
/**
865-
* Given a directory and an array of extensions... return an array of
866-
* compliant files.
867-
*
868-
* TODO Should an ignore list be passed in?
869-
* TODO Should a recurse flag be passed in?
870-
* TODO Should be rewritten using the filefilter package.
871-
* TODO Remove this method before 1.0. listFiles() variants are more flexible.
872-
*
873-
* The given extensions should be like "java" and not like ".java"
874-
* @deprecated Method is too specific. Use one of the listFiles() methods
875-
* instead. Method will be deleted before Commons IO 1.0.
876-
*/
877-
public static String[] getFilesFromExtension(
878-
String directory,
879-
String[] extensions) {
880-
881-
Collection files = new ArrayList();
882-
883-
File currentDir = new File(directory);
884-
885-
String[] unknownFiles = currentDir.list();
886-
887-
if (unknownFiles == null) {
888-
return new String[0];
889-
}
890-
891-
for (int i = 0; i < unknownFiles.length; ++i) {
892-
String currentFileName =
893-
directory
894-
+ System.getProperty("file.separator")
895-
+ unknownFiles[i];
896-
File currentFile = new java.io.File(currentFileName);
897-
898-
if (currentFile.isDirectory()) {
899-
900-
//ignore all CVS directories...
901-
if (currentFile.getName().equals("CVS")) {
902-
continue;
903-
}
904-
905-
//ok... transverse into this directory and get all the files... then combine
906-
//them with the current list.
907-
908-
String[] fetchFiles =
909-
getFilesFromExtension(currentFileName, extensions);
910-
files = blendFiles(files, fetchFiles);
911-
912-
} else {
913-
//ok... add the file
914-
915-
String add = currentFile.getAbsolutePath();
916-
if (isValidFile(add, extensions)) {
917-
files.add(add);
918-
919-
}
920-
921-
}
922-
}
923-
924-
//ok... move the Vector into the files list...
925-
926-
String[] foundFiles = new String[files.size()];
927-
files.toArray(foundFiles);
928-
929-
return foundFiles;
930-
931-
}
932-
933-
/**
934-
* Private hepler method for getFilesFromExtension()
935-
*/
936-
private static Collection blendFiles(Collection c, String[] files) {
937-
938-
for (int i = 0; i < files.length; ++i) {
939-
c.add(files[i]);
940-
}
941-
942-
return c;
943-
}
944-
945-
/**
946-
* Checks to see if a file is of a particular type(s).
947-
* Note that if the file does not have an extension, an empty string
948-
* (&quot;&quot;) is matched for.
949-
*
950-
*/
951-
private static boolean isValidFile(String file, String[] extensions) {
952-
953-
String extension = extension(file);
954-
if (extension == null) {
955-
extension = "";
956-
}
957-
958-
//ok.. now that we have the "extension" go through the current know
959-
//excepted extensions and determine if this one is OK.
960-
961-
for (int i = 0; i < extensions.length; ++i) {
962-
if (extensions[i].equals(extension))
963-
return true;
964-
}
965-
966-
return false;
967-
968-
}
969-
970863
/**
971864
* Simple way to make a directory. It also creates the parent directories
972865
* if necessary.

0 commit comments

Comments
 (0)