Java tutorial
//package com.java2s; public class Main { public static String filterWhiteSpace(char ch[], int start, int length) { int end = start + length - 1; StringBuffer buf = new StringBuffer(); char cur_char; int index = start; while (index <= end) { cur_char = ch[index]; switch (cur_char) { case '\n': case '\r': case '\t': case '\f': case ' ': break; default: buf.append(cur_char); break; } index++; } return buf.toString(); } }