📄 javamail-1.4-changes.txt
字号:
* @param limit the resource limit */ public void setResourceLimit(String name, long limit)}===================================================================20. Add ByteArrayDataSource class (4623517)-------------------------------------------The ByteArrayDataSource has been included in the JavaMail demosource code for quite some time. Quite a few applications needa class of this sort. It's time to add it as a standard API.To avoid conflicting with applications that have used the demoversion, we put this version in a new javax.mail.util package.package javax.mail.util;/** * A DataSource backed by a byte array. The byte array may be * passed in directly, or may be initialized from an InputStream * or a String. * * @since JavaMail 1.4 */public class ByteArrayDataSource implements DataSource { /** * Create a ByteArrayDataSource with data from the * specified byte array and with the specified MIME type. */ public ByteArrayDataSource(byte[] data, String type) /** * Create a ByteArrayDataSource with data from the * specified InputStream and with the specified MIME type. * The InputStream is read completely and the data is * stored in a byte array. */ public ByteArrayDataSource(InputStream is, String type) throws IOException /** * Create a ByteArrayDataSource with data from the * specified String and with the specified MIME type. * The MIME type should include a <code>charset</code> * parameter specifying the charset to be used for the * string. If the parameter is not included, the * default charset is used. */ public ByteArrayDataSource(String data, String type) throws IOException /** * Return an InputStream for the data. * Note that a new stream is returned each time * this method is called. */ public InputStream getInputStream() throws IOException /** * Return an OutputStream for the data. * Writing the data is not supported; an <code>IOException</code> * is always thrown. */ public OutputStream getOutputStream() throws IOException /** * Get the MIME content type of the data. */ public String getContentType() /** * Get the name of the data. * By default, an empty string ("") is returned. */ public String getName() /** * Set the name of the data. */ public void setName(String name)}===================================================================21. Add SharedByteArrayInputStream class (6304189)--------------------------------------------------The SharedInputStream interface allows the JavaMail implementation toefficiently process data when parsing messages, without needing tomake many copies of the data. This class is an implementation of theSharedInputStream interface that uses a byte array as the backing store.package javax.mail.util;/** * A ByteArrayInputStream that implements the SharedInputStream interface, * allowing the underlying byte array to be shared between multiple readers. * * @since JavaMail 1.4 */public class SharedByteArrayInputStream extends ByteArrayInputStream implements SharedInputStream { /** * Position within shared buffer that this stream starts at. */ protected int start; /** * Create a SharedByteArrayInputStream representing the entire * byte array. */ public SharedByteArrayInputStream(byte[] buf) /** * Create a SharedByteArrayInputStream representing the part * of the byte array from <code>offset</code> for <code>length</code> * bytes. */ public SharedByteArrayInputStream(byte[] buf, int offset, int length) /** * Return the current position in the InputStream, as an * offset from the beginning of the InputStream. * * @return the current position */ public long getPosition() /** * Return a new InputStream representing a subset of the data * from this InputStream, starting at <code>start</code> (inclusive) * up to <code>end</code> (exclusive). <code>start</code> must be * non-negative. If <code>end</code> is -1, the new stream ends * at the same place as this stream. The returned InputStream * will also implement the SharedInputStream interface. * * @param start the starting position * @param end the ending position + 1 * @return the new stream */ public InputStream newStream(long start, long end)}===================================================================22. Add SharedFileInputStream class (6304193)---------------------------------------------Finally, SharedFileInputStream is an implementation of theSharedInputStream interface that uses a file as the backing store.package javax.mail.util;/** * A <code>SharedFileInputStream</code> is a * <code>BufferedInputStream</code> that buffers * data from the file and supports the <code>mark</code> * and <code>reset</code> methods. It also supports the * <code>newStream</code> method that allows you to create * other streams that represent subsets of the file. * A <code>RandomAccessFile</code> object is used to * access the file data. * * @since JavaMail 1.4 */public class SharedFileInputStream extends BufferedInputStream implements SharedInputStream { /** * The file containing the data. * Shared by all related SharedFileInputStream instances. */ protected RandomAccessFile in; /** * The normal size of the read buffer. */ protected int bufsize; /** * The file offset that corresponds to the first byte in * the read buffer. */ protected long bufpos; /** * The file offset of the start of data in this subset of the file. */ protected long start = 0; /** * The amount of data in this subset of the file. */ protected long datalen; /** * Creates a <code>SharedFileInputStream</code> * for the file. * * @param file the file */ public SharedFileInputStream(File file) throws IOException /** * Creates a <code>SharedFileInputStream</code> * for the named file. * * @param file the file */ public SharedFileInputStream(String file) throws IOException /** * Creates a <code>SharedFileInputStream</code> * with the specified buffer size. * * @param file the file * @param size the buffer size. * @exception IllegalArgumentException if size <= 0. */ public SharedFileInputStream(File file, int size) throws IOException /** * Creates a <code>SharedFileInputStream</code> * with the specified buffer size. * * @param file the file * @param size the buffer size. * @exception IllegalArgumentException if size <= 0. */ public SharedFileInputStream(String file, int size) throws IOException /** * See the general contract of the <code>read</code> * method of <code>InputStream</code>. * * @return the next byte of data, or <code>-1</code> if the end of the * stream is reached. * @exception IOException if an I/O error occurs. */ public int read() throws IOException /** * Reads bytes from this stream into the specified byte array, * starting at the given offset. * * <p> This method implements the general contract of the corresponding * <code>{@link java.io.InputStream#read(byte[], int, int) read}</code> * method of the <code>{@link java.io.InputStream}</code> class. * * @param b destination buffer. * @param off offset at which to start storing bytes. * @param len maximum number of bytes to read. * @return the number of bytes read, or <code>-1</code> if the end of * the stream has been reached. * @exception IOException if an I/O error occurs. */ public int read(byte b[], int off, int len) throws IOException /** * See the general contract of the <code>skip</code> * method of <code>InputStream</code>. * * @param n the number of bytes to be skipped. * @return the actual number of bytes skipped. * @exception IOException if an I/O error occurs. */ public long skip(long n) throws IOException /** * Returns the number of bytes that can be read from this input * stream without blocking. * * @return the number of bytes that can be read from this input * stream without blocking. * @exception IOException if an I/O error occurs. */ public int available() throws IOException /** * See the general contract of the <code>mark</code> * method of <code>InputStream</code>. * * @param readlimit the maximum limit of bytes that can be read before * the mark position becomes invalid. * @see #reset() */ public void mark(int readlimit) /** * See the general contract of the <code>reset</code> * method of <code>InputStream</code>. * <p> * If <code>markpos</code> is <code>-1</code> * (no mark has been set or the mark has been * invalidated), an <code>IOException</code> * is thrown. Otherwise, <code>pos</code> is * set equal to <code>markpos</code>. * * @exception IOException if this stream has not been marked or * if the mark has been invalidated. * @see #mark(int) */ public void reset() throws IOException /** * Tests if this input stream supports the <code>mark</code> * and <code>reset</code> methods. The <code>markSupported</code> * method of <code>SharedFileInputStream</code> returns * <code>true</code>. * * @return a <code>boolean</code> indicating if this stream type supports * the <code>mark</code> and <code>reset</code> methods. * @see java.io.InputStream#mark(int) * @see java.io.InputStream#reset() */ public boolean markSupported() /** * Closes this input stream and releases any system resources * associated with the stream. * * @exception IOException if an I/O error occurs. */ public void close() throws IOException /** * Return the current position in the InputStream, as an * offset from the beginning of the InputStream. * * @return the current position */ public long getPosition() /** * Return a new InputStream representing a subset of the data * from this InputStream, starting at <code>start</code> (inclusive) * up to <code>end</code> (exclusive). <code>start</code> must be * non-negative. If <code>end</code> is -1, the new stream ends * at the same place as this stream. The returned InputStream * will also implement the SharedInputStream interface. * * @param start the starting position * @param end the ending position + 1 * @return the new stream */ public InputStream newStream(long start, long end) /** * Force this stream to close. */ protected void finalize() throws Throwable}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -