import java.io.*;
import java.util.Vector;
import java.util.StringTokenizer;

class TypeValue {

    public static void main(String[] args) {

	Vector list = new Vector();

	try {
	    InputStream in;
	    if (args.length < 1)
		in = System.in;
	    else
		in = new FileInputStream(args[0]);

	    LineInputStream lineIn =	// from Exercise 11.2
		new LineInputStream(in);

	    while (true) {
		String line = lineIn.readLine();
		StringTokenizer tokens = new StringTokenizer(line);
		if (tokens.countTokens() != 2)
		    error("syntax error: " + line);
		String type = tokens.nextToken();
		String value = tokens.nextToken();
		Object obj = null;
		try {
		    if (type.equalsIgnoreCase("Boolean")) {
			obj = new Boolean(value);
		    } else if (type.equalsIgnoreCase("Character")) {
			if (value.length() != 1)
			    throw new NumberFormatException(value);
			char ch = value.charAt(0);
			obj = new Character(ch);
		    } else if (type.equalsIgnoreCase("Double")) {
			obj = new Double(value);
		    } else if (type.equalsIgnoreCase("Float")) {
			obj = new Float(value);
		    } else if (type.equalsIgnoreCase("Integer")) {
			obj = new Integer(value);
		    } else if (type.equalsIgnoreCase("Long")) {
			obj = new Long(value);
		    } else
			error("invalid type: " + type);
		} catch (NumberFormatException e) {
		    error("invalid value: " + value);
		}
		list.addElement(obj);
	    }
	} catch (EOFException ignore) {
	} catch (IOException e) {
	    error("I/O Exception: " + e);
	}

	for (int i = 0; i < list.size(); i++) {
	    Object obj = list.elementAt(i);
	    System.out.println(obj.getClass().getName() + "\t\t" + obj);
	}
    }

    public static void error(String err) {
	System.err.println("TypeValue: " + err);
	System.exit(1); // non-zero argument means "not good"
    }
}



Note that with the Reflection API available in Java 1.1, the large
if/else structure with a special case for each type could be replaced
with code that finds the appropriate wrapper class by name and uses
reflection to invoke its constructor that takes a single string
argument.
