|
62 | 62 | import java.io.FileFilter; |
63 | 63 | import java.io.OutputStream; |
64 | 64 | import java.net.URL; |
65 | | -import java.util.ArrayList; |
66 | 65 | import java.util.Collection; |
67 | 66 | import java.util.Date; |
68 | 67 |
|
|
117 | 116 | * @author <a href="mailto:jefft@apache.org">Jeff Turner</a> |
118 | 117 | * @author Matthew Hawthorne |
119 | 118 | * @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 $ |
121 | 120 | */ |
122 | 121 | public class FileUtils { |
123 | 122 |
|
@@ -861,112 +860,6 @@ public static void fileDelete(String fileName) { |
861 | 860 | file.delete(); |
862 | 861 | } |
863 | 862 |
|
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 | | - * ("") 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 | | - |
970 | 863 | /** |
971 | 864 | * Simple way to make a directory. It also creates the parent directories |
972 | 865 | * if necessary. |
|
0 commit comments