public static int convertObjectToInt(Object obj) {
	if (obj.getClass().toString().contains("Integer")) {
		return (Integer) obj;
	}
	if (obj.getClass().toString().contains("String")) {
		return convertStringToInt((String) obj);
	}
	Ts.printErr("error on converting to integer");
	//----- it never be reached
	return -1;
}
 
public static int convertStringToInt(String str) {
	return Integer.parseInt(str);
}
 
public static void printErr(String str) {
	System.out.println("---> error : " + str);
	System.exit(-1);
}


Back to JavaHowTo

Alumni Liaison

BSEE 2004, current Ph.D. student researching signal and image processing.

Landis Huffman