Here you can find the source of toCharacter(String input, char defaultValue)
public static char toCharacter(String input, char defaultValue)
//package com.java2s; //License from project: Apache License public class Main { public static char toCharacter(String input, char defaultValue) { if (input == null) { return defaultValue; }/*from w w w.j av a 2s. co m*/ if (input.length() == 1) { return input.charAt(0); } else { return defaultValue; } } }