Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static String removeBlanks(String content) { if (content == null) { return null; } StringBuilder buff = new StringBuilder(); buff.append(content); for (int i = buff.length() - 1; i >= 0; i--) { if (' ' == buff.charAt(i) || ('\n' == buff.charAt(i)) || ('\t' == buff.charAt(i)) || ('\r' == buff.charAt(i))) { buff.deleteCharAt(i); } } return buff.toString(); } }