1 23 package org.objectweb.clif.scenario.util.isac.plugin; 24 import java.io.File ; 25 import java.util.Vector ; 26 27 import org.apache.log4j.Category; 28 34 public class SearchPluginFile { 35 static Category cat = Category.getInstance(SearchPluginFile.class.getName()); 36 41 public static String [] searchPlugins(String dirName, String fileName) { 42 cat.debug("-> searchPlugins") ; 43 try { 44 File dir = new File (dirName); 45 File [] files = dir.listFiles(); 46 if (files == null) { 47 return null; 48 } 49 Vector result = new Vector (); 50 for (int i = 0; i < files.length; i++) { 51 if (files[i].isDirectory()) { 52 String [] temp = searchPlugins(dirName + files[i].getName(), fileName); 53 if (temp == null) 54 continue; 55 for (int j = 0; j < temp.length; j++) 56 result.add(temp[j]); 57 } else if (files[i].isFile()) { 58 if (((String ) (files[i].getName())).equals(fileName)) 59 result.add(dirName + "/" ); 60 } else 61 cat.warn( 62 "File is not reconize : " + files[i].getName()); 63 } 64 if (result != null) 65 return (String []) result.toArray(new String [0]); 66 } catch (Exception e) { 67 e.printStackTrace(); 68 System.exit(0); 69 } 70 return null; 72 } 73 } 74 | Popular Tags |