encoding.equalsIgnoreCase("x-uuencode") || encoding.equalsIgnoreCase("x-uue")) return new UUDecoderStream(is); else if (encoding.equalsIgnoreCase("binary") || encoding.equalsIgnoreCase("7bit") ||
/** * Read the next decoded byte from this input stream. The byte * is returned as an <code>int</code> in the range <code>0</code> * to <code>255</code>. If no byte is available because the end of * the stream has been reached, the value <code>-1</code> is returned. * This method blocks until input data is available, the end of the * stream is detected, or an exception is thrown. * * @return next byte of data, or <code>-1</code> if the end of * stream is reached. * @exception IOException if an I/O error occurs. * @see java.io.FilterInputStream#in */ public int read() throws IOException { if (index >= bufsize) { readPrefix(); if (!decode()) return -1; index = 0; // reset index into buffer } return buffer[index++] & 0xff; // return lower byte }
public int read(byte[] buf, int off, int len) throws IOException { int i, c; for (i = 0; i < len; i++) { if ((c = read()) == -1) { if (i == 0) // At end of stream, so we should i = -1; // return -1, NOT 0. break; } buf[off+i] = (byte)c; } return i; }
/** * Get the "name" field from the prefix. This is meant to * be the pathname of the decoded file * * @return name of decoded file * @exception IOException if an I/O error occurs. */ public String getName() throws IOException { readPrefix(); return name; }
/** * Get the "mode" field from the prefix. This is the permission * mode of the source file. * * @return permission mode of source file * @exception IOException if an I/O error occurs. */ public int getMode() throws IOException { readPrefix(); return mode; }
/** * Read the next decoded byte from this input stream. The byte * is returned as an <code>int</code> in the range <code>0</code> * to <code>255</code>. If no byte is available because the end of * the stream has been reached, the value <code>-1</code> is returned. * This method blocks until input data is available, the end of the * stream is detected, or an exception is thrown. * * @return next byte of data, or <code>-1</code> if the end of * stream is reached. * @exception IOException if an I/O error occurs. * @see java.io.FilterInputStream#in */ @Override public int read() throws IOException { if (index >= bufsize) { readPrefix(); if (!decode()) return -1; index = 0; // reset index into buffer } return buffer[index++] & 0xff; // return lower byte }
/** * Get the "name" field from the prefix. This is meant to * be the pathname of the decoded file * * @return name of decoded file * @exception IOException if an I/O error occurs. */ public String getName() throws IOException { readPrefix(); return name; }
encoding.equalsIgnoreCase("x-uuencode") || encoding.equalsIgnoreCase("x-uue")) return new UUDecoderStream(is); else if (encoding.equalsIgnoreCase("binary") || encoding.equalsIgnoreCase("7bit") ||
@Override public int read(byte[] buf, int off, int len) throws IOException { int i, c; for (i = 0; i < len; i++) { if ((c = read()) == -1) { if (i == 0) // At end of stream, so we should i = -1; // return -1, NOT 0. break; } buf[off+i] = (byte)c; } return i; }
/** * Read the next decoded byte from this input stream. The byte * is returned as an <code>int</code> in the range <code>0</code> * to <code>255</code>. If no byte is available because the end of * the stream has been reached, the value <code>-1</code> is returned. * This method blocks until input data is available, the end of the * stream is detected, or an exception is thrown. * * @return next byte of data, or <code>-1</code> if the end of * stream is reached. * @exception IOException if an I/O error occurs. * @see java.io.FilterInputStream#in */ @Override public int read() throws IOException { if (index >= bufsize) { readPrefix(); if (!decode()) return -1; index = 0; // reset index into buffer } return buffer[index++] & 0xff; // return lower byte }
/** * Get the "mode" field from the prefix. This is the permission * mode of the source file. * * @return permission mode of source file * @exception IOException if an I/O error occurs. */ public int getMode() throws IOException { readPrefix(); return mode; }
/** * Decode the given input stream. The Input stream returned is * the decoded input stream. All the encodings defined in RFC 2045 * are supported here. They include "base64", "quoted-printable", * "7bit", "8bit", and "binary". In addition, "uuencode" is also * supported. * * @param is input stream * @param encoding the encoding of the stream. * @return decoded input stream. */ public static InputStream decode(InputStream is, String encoding) throws MessagingException { if (encoding.equalsIgnoreCase("base64")) return new BASE64DecoderStream(is); else if (encoding.equalsIgnoreCase("quoted-printable")) return new QPDecoderStream(is); else if (encoding.equalsIgnoreCase("uuencode") || encoding.equalsIgnoreCase("x-uuencode") || encoding.equalsIgnoreCase("x-uue")) return new UUDecoderStream(is); else if (encoding.equalsIgnoreCase("binary") || encoding.equalsIgnoreCase("7bit") || encoding.equalsIgnoreCase("8bit")) return is; else throw new MessagingException("Unknown encoding: " + encoding); }
public int read(byte[] buf, int off, int len) throws IOException { int i, c; for (i = 0; i < len; i++) { if ((c = read()) == -1) { if (i == 0) // At end of stream, so we should i = -1; // return -1, NOT 0. break; } buf[off+i] = (byte)c; } return i; }
/** * Read the next decoded byte from this input stream. The byte * is returned as an <code>int</code> in the range <code>0</code> * to <code>255</code>. If no byte is available because the end of * the stream has been reached, the value <code>-1</code> is returned. * This method blocks until input data is available, the end of the * stream is detected, or an exception is thrown. * * @return next byte of data, or <code>-1</code> if the end of * stream is reached. * @exception IOException if an I/O error occurs. * @see java.io.FilterInputStream#in */ @Override public int read() throws IOException { if (index >= bufsize) { readPrefix(); if (!decode()) return -1; index = 0; // reset index into buffer } return buffer[index++] & 0xff; // return lower byte }
/** * Get the "mode" field from the prefix. This is the permission * mode of the source file. * * @return permission mode of source file * @exception IOException if an I/O error occurs. */ public int getMode() throws IOException { readPrefix(); return mode; }
encoding.equalsIgnoreCase("x-uuencode") || encoding.equalsIgnoreCase("x-uue")) return new UUDecoderStream(is); else if (encoding.equalsIgnoreCase("binary") || encoding.equalsIgnoreCase("7bit") ||
public int read(byte[] buf, int off, int len) throws IOException { int i, c; for (i = 0; i < len; i++) { if ((c = read()) == -1) { if (i == 0) // At end of stream, so we should i = -1; // return -1, NOT 0. break; } buf[off+i] = (byte)c; } return i; }
/** * Read the next decoded byte from this input stream. The byte * is returned as an <code>int</code> in the range <code>0</code> * to <code>255</code>. If no byte is available because the end of * the stream has been reached, the value <code>-1</code> is returned. * This method blocks until input data is available, the end of the * stream is detected, or an exception is thrown. * * @return next byte of data, or <code>-1</code> if the end of * stream is reached. * @exception IOException if an I/O error occurs. * @see java.io.FilterInputStream#in */ public int read() throws IOException { if (index >= bufsize) { readPrefix(); if (!decode()) return -1; index = 0; // reset index into buffer } return buffer[index++] & 0xff; // return lower byte }
/** * Get the "mode" field from the prefix. This is the permission * mode of the source file. * * @return permission mode of source file * @exception IOException if an I/O error occurs. */ public int getMode() throws IOException { readPrefix(); return mode; }
encoding.equalsIgnoreCase("x-uuencode") || encoding.equalsIgnoreCase("x-uue")) return new UUDecoderStream(is); else if (encoding.equalsIgnoreCase("binary") || encoding.equalsIgnoreCase("7bit") ||