1 33 34 package edu.rice.cs.util; 35 36 import java.net.URL ; 37 import java.net.MalformedURLException ; 38 import java.io.File ; 39 import java.util.ArrayList ; 40 41 44 public class ClassPathVector extends ArrayList <URL > { 45 46 public ClassPathVector() { } 47 48 public ClassPathVector(int capacity) { super(capacity); } 49 50 public String toString() { 51 final StringBuilder cp = new StringBuilder (); 52 for(URL u : this) { 53 cp.append(formatURL(u)); 54 cp.append(File.pathSeparator); 55 } 56 return cp.toString(); 57 } 58 59 60 public void add(String entry) { 61 try { 62 this.add(new URL (entry)); 63 } catch(MalformedURLException e) { 64 } 68 } 69 70 71 public void add(File entry) { 72 try { add(FileOps.toURL(entry)); } 73 catch(MalformedURLException e) { 74 } 78 } 79 80 public ArrayList <File > asFileVector() { 81 ArrayList <File > v = new ArrayList <File >(); 82 for(URL url : this) { v.add(new File (url.getFile())); } 83 return v; 84 } 85 86 private String formatURL(URL url) { return new File (url.getFile()).toString(); } 87 } 88 | Popular Tags |