package com.iwunu.iot.common.util;

import java.io.UnsupportedEncodingException;
import java.util.regex.Pattern;

public class StringUtil {
	
	public static String encoding(byte[] src, String encoding){
		try {
			return new String(src, encoding);
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException(e.getMessage(), e);
		}
	}

	public static boolean isNumber(String str) {
		Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
		return pattern.matcher(str).matches();
	}

	public static void main(String[] args) {
		System.out.println(isNumber("a"));
	}

	public static boolean strIsNullOrEmpty(String s) {
		return (null == s || s.trim().length() < 1);
	}
	public static boolean strIsNullOrEmpty(Object s) {
		return (null == s || s.toString().trim().length() < 1);
	}
}
