if (argv.length < 1) {
System.exit(1);
}
try {
String bundleName = argv[0] + "_" + Locale.getDefault().toString();
Properties propertiesFile = new Properties();
propertiesFile.load(new FileInputStream(bundleName + ".properties"));
FileWriter fw = new FileWriter(bundleName + ".java");
String key;
fw.write("import java.util.ListResourceBundle;\n\n");
fw.write("public class " + bundleName +
" extends ListResourceBundle {\n\n");
fw.write(" public Object [][] getContents() {\n");
fw.write(" return contents;\n");
fw.write(" }\n\n");
fw.write(" static final Object [][] contents = {\n");
Enumeration e = propertiesFile.propertyNames();
while (e.hasMoreElements()) {
key = (String)e.nextElement();
fw.write(" {\"" + key + "\", " + "\""
+ propertiesFile.getProperty(key) + "\"},\n");
}
fw.write(" {\"PropertyToListResourceBundleCreator\", "
+ "\"O'Reilly\"}\n");
fw.write(" };\n");
fw.write("}\n");
fw.close();
} catch (MissingResourceException mre) {
mre.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}