Here you can find the source of toByte(Object value)
public static Byte toByte(Object value)
//package com.java2s; //License from project: Apache License public class Main { /**/*from w w w . j a v a 2 s . co m*/ * Convert an Object to a Byte. */ public static Byte toByte(Object value) { if (value == null) return null; if (value instanceof Byte) return (Byte) value; if (value instanceof String) { if ("".equals((String) value)) return null; return new Byte((String) value); } if (value instanceof Number) return new Byte(((Number) value).byteValue()); return new Byte(value.toString()); } /** * Convert an Object to a byte, or 0 if it is null. */ public static byte byteValue(Object value) { if (value == null) return 0; return toByte(value).byteValue(); } }