Java examples for java.lang:String Parse
Parse String to Byte value with default value
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { String value = "java2s.com"; System.out.println(getByte(value)); }// w ww . j a v a 2 s .com public static Byte getByte(String value, Byte defaultValue) { try { return Byte.valueOf(value); } catch (Exception ex) { return defaultValue; } } public static Byte getByte(String value) { return getByte(value, null); } }