Java tutorial
//package com.java2s; //License from project: Apache License import android.text.TextUtils; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static String trimNewLine(String str) { if (TextUtils.isEmpty(str)) return ""; str = str.trim(); Pattern p = Pattern.compile("\t|\r|\n"); Matcher m = p.matcher(str); String dest = m.replaceAll(""); return dest; } }