FileDocCategorySizeDatePackage
QDecoderStream.javaAPI DocJavaMail 1.4.33498Tue Nov 17 10:38:12 GMT 2009com.sun.mail.util

QDecoderStream

public class QDecoderStream extends QPDecoderStream
This class implements a Q Decoder as defined in RFC 2047 for decoding MIME headers. It subclasses the QPDecoderStream class.
author
John Mani

Fields Summary
Constructors Summary
public QDecoderStream(InputStream in)
Create a Q-decoder that decodes the specified input stream.

param
in the input stream

	super(in);
    
Methods Summary
public intread()
Read the next decoded byte from this input stream. The byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

return
the next byte of data, or -1 if the end of the stream is reached.
exception
IOException if an I/O error occurs.

	int c = in.read();

	if (c == '_") // Return '_' as ' '
	    return ' ";
	else if (c == '=") {
	    // QP Encoded atom. Get the next two bytes ..
	    ba[0] = (byte)in.read();
	    ba[1] = (byte)in.read();
	    // .. and decode them
	    try {
		return ASCIIUtility.parseInt(ba, 0, 2, 16);
	    } catch (NumberFormatException nex) {
		throw new DecodingException(
			"QDecoder: Error in QP stream " + nex.getMessage());
	    }
	} else
	    return c;