1 21 package proguard; 22 23 import java.io.*; 24 25 26 32 public class ArgumentWordReader extends WordReader 33 { 34 private String [] arguments; 35 private int index = 0; 36 37 38 51 public ArgumentWordReader(String [] arguments, File baseDir) 52 { 53 super(baseDir); 54 55 this.arguments = arguments; 56 } 57 58 59 61 protected String nextLine() throws IOException 62 { 63 return index < arguments.length ? 64 arguments[index++] : 65 null; 66 } 67 68 69 protected String lineLocationDescription() 70 { 71 return "argument number " + index; 72 } 73 74 75 79 public static void main(String [] args) { 80 81 try 82 { 83 WordReader reader = new ArgumentWordReader(args, null); 84 85 try 86 { 87 while (true) 88 { 89 String word = reader.nextWord(); 90 if (word == null) 91 System.exit(-1); 92 93 System.err.println("["+word+"]"); 94 } 95 } 96 catch (Exception ex) 97 { 98 ex.printStackTrace(); 99 } 100 finally 101 { 102 reader.close(); 103 } 104 } 105 catch (IOException ex) 106 { 107 ex.printStackTrace(); 108 } 109 } 110 } 111 | Popular Tags |