Java tutorial
//package com.java2s; public class Main { public static String filter(String xmlStr) { StringBuilder sb = new StringBuilder(); char[] chs = xmlStr.toCharArray(); //log.debug("filter before=" +chs.length); for (char ch : chs) { if ((ch >= 0x00 && ch <= 0x08) || (ch >= 0x0b && ch <= 0x0c) || (ch >= 0x0e && ch <= 0x1f)) { //eat... } else { sb.append(ch); } } //log.debug("filter after=" +sb.length()); return sb.toString(); } }