Java tutorial
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { private static String __htmlTextToPlainText(String text) { text = text.replace("<", "<"); text = text.replace(">", ">"); return text; } private static void __htmlTextToPlainText(String text, Writer writer) throws IOException { StringReader sr = new StringReader(text); char[] chunk = new char[1024 * 64]; while (true) { int charsRead = sr.read(chunk, 0, chunk.length); if (charsRead <= 0) break; int lastPos = 0; for (int i = 0; i < chunk.length; i++) { if (chunk[i] == '<') { writer.write(chunk, lastPos, i - lastPos); writer.write("<"); lastPos = i + 1; } else if (chunk[i] == '>') { writer.write(chunk, lastPos, i - lastPos); writer.write(">"); lastPos = i + 1; } } if (lastPos < chunk.length) { writer.write(chunk, lastPos, chunk.length - lastPos); } } } }