1 import java.io.*; 2 import java.util.*; 3 4 public class FileReaderTest { 5 6 public static void main(String [] args) { 7 8 for (int i = 0; i < args.length; i++) { 9 10 try { 11 BufferedReader br = new BufferedReader(new FileReader(args[i])); 12 13 StringTokenizer st = new StringTokenizer(br.readLine()); 14 15 myMethod(StringToInt(st.nextToken()), StringToInt(st.nextToken()), st.nextToken()); 16 17 String line; 18 while ((line = br.readLine()) != "done") { 19 StringTokenizer st2 = new StringTokenizer(line); 20 myOtherMethod(StringToInt(st2.nextToken()), StringToInt(st2.nextToken())); 21 } 22 23 } 24 catch(IOException e) { 25 System.out.println("Error: "+e); 26 } 27 28 } 29 } 30 31 private static void myOtherMethod(int i, int j) { 32 System.out.println(i+j); 33 } 34 35 private static void myMethod(int i, int j, String s) { 36 System.out.println(i+j+s); 37 } 38 39 private static int StringToInt(String s) { 40 41 return (new Integer (s)).intValue(); 42 } 43 } 44 | Popular Tags |