1 44 45 package org.jfree.io; 46 47 import java.io.File ; 48 import java.util.StringTokenizer ; 49 50 55 public class FileUtilities { 56 57 60 private FileUtilities() { 61 } 62 63 72 public static File findFileOnClassPath(final String name) { 73 74 final String classpath = System.getProperty("java.class.path"); 75 final String pathSeparator = System.getProperty("path.separator"); 76 77 final StringTokenizer tokenizer = new StringTokenizer (classpath, pathSeparator); 78 79 while (tokenizer.hasMoreTokens()) { 80 final String pathElement = tokenizer.nextToken(); 81 82 final File directoryOrJar = new File (pathElement); 83 final File absoluteDirectoryOrJar = directoryOrJar.getAbsoluteFile(); 84 85 if (absoluteDirectoryOrJar.isFile()) { 86 final File target = new File (absoluteDirectoryOrJar.getParent(), name); 87 if (target.exists()) { 88 return target; 89 } 90 } 91 else { 92 final File target = new File (directoryOrJar, name); 93 if (target.exists()) { 94 return target; 95 } 96 } 97 98 } 99 return null; 100 101 } 102 103 } 104 | Popular Tags |