Java - Write code to check if a string is representing a Long value

Requirements

Write code to check if a string is representing a Long value

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String src = "book2s.com";
        System.out.println(isLong(src));
    }/* w ww .ja  v  a2 s .co m*/

    public static boolean isLong(String src) {
        if (src == null || src.equals(""))
            return false;
        try {
            Long.parseLong(src);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}