List of usage examples for java.io StringReader read
public int read(char cbuf[], int off, int len) throws IOException
From source file:Main.java
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;// w w w .j av a 2 s . c o m } 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); } } }