29 import java.io.IOException;
30 import java.lang.String;
31 import java.util.StringTokenizer;
32 import java.net.URL;
33 import java.net.URLClassLoader;
34 import java.net.MalformedURLException;
35
36 /**
37 * A utility class for handle path list
38 *
39 */
40 public class PathList {
41 /**
42 * Utility method for appending path from pathFrom to pathTo.
43 *
44 * @param pathTo the target path
45 * @param pathFrom the path to be appended to pathTo
46 * @return the resulting path
47 */
48 public static String appendPath(String pathTo, String pathFrom) {
49 if (pathTo == null || pathTo.length() == 0) {
50 return pathFrom;
51 } else if (pathFrom == null || pathFrom.length() == 0) {
52 return pathTo;
53 } else {
54 return pathTo + File.pathSeparator + pathFrom;
55 }
56 }
57
58 /**
59 * Utility method for converting a search path string to an array
60 * of directory and JAR file URLs.
61 *
62 * @param path the search path string
63 * @return the resulting array of directory and JAR file URLs
64 */
65 public static URL[] pathToURLs(String path) {
66 StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
67 URL[] urls = new URL[st.countTokens()];
68 int count = 0;
69 while (st.hasMoreTokens()) {
70 URL url = fileToURL(new File(st.nextToken()));
71 if (url != null) {
|
29 import java.io.IOException;
30 import java.lang.String;
31 import java.util.StringTokenizer;
32 import java.net.URL;
33 import java.net.URLClassLoader;
34 import java.net.MalformedURLException;
35
36 /**
37 * A utility class for handle path list
38 *
39 */
40 public class PathList {
41 /**
42 * Utility method for appending path from pathFrom to pathTo.
43 *
44 * @param pathTo the target path
45 * @param pathFrom the path to be appended to pathTo
46 * @return the resulting path
47 */
48 public static String appendPath(String pathTo, String pathFrom) {
49 if (pathTo == null || pathTo.isEmpty()) {
50 return pathFrom;
51 } else if (pathFrom == null || pathFrom.isEmpty()) {
52 return pathTo;
53 } else {
54 return pathTo + File.pathSeparator + pathFrom;
55 }
56 }
57
58 /**
59 * Utility method for converting a search path string to an array
60 * of directory and JAR file URLs.
61 *
62 * @param path the search path string
63 * @return the resulting array of directory and JAR file URLs
64 */
65 public static URL[] pathToURLs(String path) {
66 StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
67 URL[] urls = new URL[st.countTokens()];
68 int count = 0;
69 while (st.hasMoreTokens()) {
70 URL url = fileToURL(new File(st.nextToken()));
71 if (url != null) {
|