Java tutorial
//package com.java2s; public class Main { public static String formatPhone(String phone) { if (!checkString(phone)) { return phone; } phone = phone.replace("-", ""); phone = phone.replace(" ", ""); return phone; } public static boolean checkString(String src) { if (src == null) { return false; } if (src.trim().length() == 0) { return false; } return true; } }