make/jdk/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java
branchJDK-8215445-branch
changeset 57074 12615de8335e
parent 47216 71c04702a3d5
child 57083 947cfcf92dbe
--- a/make/jdk/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java	Fri Dec 14 17:08:58 2018 -0800
+++ b/make/jdk/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java	Fri Dec 14 17:12:14 2018 -0800
@@ -28,7 +28,9 @@
 import java.io.IOException;
 import java.io.FileNotFoundException;
 import java.io.DataOutputStream;
+import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.InputStream;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
@@ -134,19 +136,44 @@
     private static String currenciesWithMinorUnitsUndefined;
 
     public static void main(String[] args) {
-
+	    InputStream in = System.in;
         // Look for "-o outputfilename" option
-        if ( args.length == 2 && args[0].equals("-o") ) {
-            try {
-                out = new DataOutputStream(new FileOutputStream(args[1]));
-            } catch ( FileNotFoundException e ) {
-                System.err.println("Error: " + e.getMessage());
-                e.printStackTrace(System.err);
-                System.exit(1);
-            }
-        } else {
-            System.err.println("Error: Illegal arg count");
-            System.exit(1);
+        for (int n = 0; n < args.length; ++n) {
+            if (args[n].equals("-o")) {
+				++n;
+				if (n >= args.length) {
+					System.err.println("Error: Invalid argument format");
+					System.exit(1);
+				}
+				try {
+					out = new DataOutputStream(new FileOutputStream(args[n]));
+				} catch ( FileNotFoundException e ) {
+					System.err.println("Error: " + e.getMessage());
+					e.printStackTrace(System.err);
+					System.exit(1);
+				}
+			} else if (args[n].equals("-i")) {
+				++n;
+				if (n >= args.length) {
+					System.err.println("Error: Invalid argument format");
+					System.exit(1);
+				}
+				try {
+					in = new FileInputStream(args[n]);
+				} catch ( FileNotFoundException e ) {
+					System.err.println("Error: " + e.getMessage());
+					e.printStackTrace(System.err);
+					System.exit(1);
+				}
+			} else {
+				System.err.println("Error: Invalid argument " + args[n]);
+				System.exit(1);
+			}
+        }
+
+        if (out == null) {
+			System.err.println("Error: Invalid argument format");
+			System.exit(1);
         }
 
         format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.US);
@@ -154,7 +181,7 @@
         format.setLenient(false);
 
         try {
-            readInput();
+            readInput(in);
             buildMainAndSpecialCaseTables();
             buildOtherTables();
             writeOutput();
@@ -167,9 +194,9 @@
         }
     }
 
-    private static void readInput() throws IOException {
+    private static void readInput(InputStream in) throws IOException {
         currencyData = new Properties();
-        currencyData.load(System.in);
+        currencyData.load(in);
 
         // initialize other lookup strings
         formatVersion = (String) currencyData.get("formatVersion");