Java tutorial
//package com.java2s; import android.text.TextUtils; public class Main { public static String nullsafeTrim(String str) { return TextUtils.isEmpty(str) ? str : str.trim(); } }