DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30864>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30864

[codec] Document how to print a QPDecoderStream with QCodec?





------- Additional Comments From [EMAIL PROTECTED]  2004-08-28 10:31 -------
thanks for the update.
I solved the problem by just converting the QPDecoderStream to a
ByteArrayInputStream before doing anything else. This has the effect that the
content is already decoded in the newly created InputStream.

if (fileStream instanceof QPDecoderStream) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            BufferedInputStream bis = new BufferedInputStream(fileStream);
            while (true) {
                int c = bis.read();
                if (c == -1)
                    break;
                baos.write(c);
            }
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e.getMessage());
            throw new DefaultException(e.getMessage());
        }
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        bais.reset();
                this.fileStream = bais;
}


Also looked at mail-1.0\source\gnu\mail\util\QPInputStream.java, but this didn't
appear to help.

So printing the QPDecoderStream AFTER the above conversion is trivial:
BufferedInputStream bis = new BufferedInputStream(this.fileStream);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            while (true) {
                int c = bis.read();
                if (c == -1)
                    break;
                baos.write(c);
            }
            String quotPrintableDecoded = new String(baos.toByteArray());
            log.debug(quotPrintableDecoded);


see also Bug 20815

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to