1 2 package SOFA.Tools.Resolver; 3 4 import java.io.BufferedReader ; 5 import java.io.FileInputStream ; 6 import java.io.FileOutputStream ; 7 import java.io.FileReader ; 8 9 13 public class TestMain { 14 19 public static final void main(String [] argv) throws Exception { 20 java.util.Hashtable trTable = readTable(argv[0]); 21 Resolver resolver = new Resolver(trTable); 22 for(int i=1; i<argv.length; i++) { 23 String newName = (String ) trTable.get(argv[i].substring(0, argv[i].length()-6)); 24 if (newName == null) { 25 newName = argv[i].substring(0, argv[i].length()-6); 26 System.out.println("WARNING: file "+argv[i]+" will be rewritten."); 27 } 28 System.out.print("Processing file "+argv[i]+"..."); 29 FileInputStream is = new FileInputStream (argv[i]); 30 byte[] b = resolver.process(is); 31 is.close(); 32 FileOutputStream os = new FileOutputStream (newName+".class"); 33 os.write(b); 34 os.close(); 35 System.out.println("OK"); 36 } 37 } 38 39 private static java.util.Hashtable readTable(String fname) throws Exception { 40 java.util.Hashtable trTable = new java.util.Hashtable (); 41 BufferedReader ir = new BufferedReader (new FileReader (fname)); 42 String ln; 43 while ((ln = ir.readLine()) != null) { 44 int sp = ln.indexOf(' '); 45 if (sp != -1) 46 trTable.put(ln.substring(0,sp), ln.substring(sp+1)); 47 } 48 ir.close(); 49 return trTable; 50 } 51 } 52 | Popular Tags |