Java Is Null isNull(Object s)

Here you can find the source of isNull(Object s)

Description

is Null

License

Open Source License

Declaration

public static boolean isNull(Object s) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.UnsupportedEncodingException;

public class Main {

    public static boolean isNull(Object s) {
        return isBlank(nullValue(s));
    }// ww w .j  a v  a  2  s  .co  m

    public static boolean isBlank(Object s) {
        return (s == null) || (nullValue(s).trim().length() == 0);
    }

    public static String nullValue(String s) {
        return s == null ? "" : s.trim();
    }

    public static String nullValue(Object s) {
        return s == null ? "" : s.toString();
    }

    public static String nullValue(long s) {
        return s < 0L ? "" : String.valueOf(s);
    }

    public static String nullValue(int s) {
        return s < 0 ? "" : "" + s;
    }

    public static String trim(String s) {
        if (s == null) {
            return "";
        }
        return s.trim();
    }

    public static String toString(byte[] b, int offset, int length, String charset) {
        try {
            return new String(b, offset, length, charset);
        } catch (UnsupportedEncodingException e) {
            throw new IllegalArgumentException(e);
        }

    }
}

Related

  1. isNotNull(File file)
  2. isNotNullOrEmpty(final Object[] array)
  3. isNull(File file)
  4. isNull(String sIn)
  5. isNullOrEmpty(Object[] array)