FileDocCategorySizeDatePackage
ListResourceBundleCreator.javaAPI DocExample3267Mon Jan 15 13:57:46 GMT 2001None

ListResourceBundleCreator

public class ListResourceBundleCreator extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] argv)

    FileInputStream inputFileReader = new FileInputStream(argv[0]);
    DataInputStream dis = new DataInputStream(inputFileReader);
    long fileSize;

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Vector myVector = new Vector();

    while (true) {
      try {
        myVector.addElement(new Integer(dis.readUnsignedByte()));
      } catch (EOFException e) {
        break;
      }
    }

    fileSize = myVector.size();
    FileWriter outputFileWriter = new FileWriter(argv[2] + ".java");
    outputFileWriter.write("import java.util.ListResourceBundle;\n\n");
    outputFileWriter.write("public class " + argv[2] +
                           " extends ListResourceBundle {\n\n");
    outputFileWriter.write("    public Object [][] getContents() {\n");
    outputFileWriter.write("        return contents;\n");
    outputFileWriter.write("    }\n\n");

    outputFileWriter.write("    static byte [] " + argv[1] + " = {\n");
    for (int i = 0; i < fileSize; i++) {
        outputFileWriter.write("\t(byte)");
        outputFileWriter.write(((Integer)myVector.elementAt(i)).toString());
        if (i < fileSize - 1)
            outputFileWriter.write(",\n");
    }
    outputFileWriter.write("\n\t};\n\n");

    outputFileWriter.write("    static final Object [][] contents = {\n");
    outputFileWriter.write("        {\"" + argv[1] + "\", " + argv[1] + "}\n");
    outputFileWriter.write("    };\n");
    outputFileWriter.write("}\n");
    outputFileWriter.close();