/**
*
* The pure content text is just an assembly of all strings that occur within the content stream in * stream order. * Each of these strings will be set on a new line. *
* * @param stream_bytes The content stream. * @return Returns the extracted string. * @throws IOException Forwarded exception. */ public static String extractPureTextFromContentStream( final byte[] stream_bytes) throws IOException { // logger_.debug("stream_bytes:"); // logger_.debug(new String(stream_bytes, "US-ASCII")); // logger_.debug(":end of stream_bytes"); final byte OPEN = '('; final byte CLOSE = ')'; StringWriter strwrtr = new StringWriter(); PrintWriter printer = new PrintWriter(strwrtr); int open_index = -1; int close_index = -1; for (int i = 0; i < stream_bytes.length; i++) { if (stream_bytes[i] == OPEN) { open_index = i; continue; } if (stream_bytes[i] == CLOSE) { close_index = i; // logger_.debug("open = " + open_index + ", close = " + // close_index); int len = close_index - open_index - 1; // logger_.debug("len = " + len); byte[] bytes = new byte[len]; System.arraycopy(stream_bytes, open_index + 1, bytes, 0, len); String str = new String(bytes, "ISO-8859-1"); // logger_.debug("string = " + str); printer.println(str); continue; } } strwrtr.close(); String signature_text = new String(strwrtr.getBuffer()); // logger_.debug(signature_text); return signature_text; } }