Here you can find the source of toLong(String str)
public static Long toLong(String str)
//package com.java2s; //License from project: Open Source License public class Main { public static Long toLong(String str) { if (isEmpty(str)) return null; try {//from w w w. j a v a2 s .c o m return Long.parseLong(str); } catch (Exception e) { e.printStackTrace(); return null; } } public static Long toLong(String str, Long defaultValue) { Long value = toLong(str); return value == null ? defaultValue : value; } public static boolean isEmpty(String str) { return !notEmpty(str); } public static boolean notEmpty(String str) { return str != null && str.trim().length() > 0; } }