Here you can find the source of toByte(Object obj)
public static byte toByte(Object obj)
//package com.java2s; //License from project: Open Source License public class Main { public static byte toByte(Object obj) { return toByte(obj, (byte) 0); }/*from w w w.java2 s. c o m*/ public static byte toByte(Object obj, byte defaultValue) { if (obj == null) { return defaultValue; } if (obj instanceof Number) { Number number = (Number) obj; return number.byteValue(); } String value = toString(obj); try { return Byte.parseByte(value); } catch (Exception e) { } return defaultValue; } public static String toString(Object value) { if (value == null) { return ""; } return value.toString().trim(); } }