/** * Can get the attachment part's content multiple times. That means * the full content needs to be there in memory or on the file system. * Calling this method would trigger parsing for the part's data. So * do not call this unless it is required(otherwise, just wrap MIMEPart * into a object that returns InputStream for e.g DataHandler) * * @return data for the part's content */ public InputStream read() { if (readOnce) { throw new IllegalStateException("readOnce() is called before, read() cannot be called later."); } // Trigger parsing for the part while(tail == null) { if (!part.msg.makeProgress()) { throw new IllegalStateException("No such MIME Part: "+part); } } if (head == null) { throw new IllegalStateException("Already read. Probably readOnce() is called before."); } return new ReadMultiStream(); }
@Override public int read(byte b[], int off, int sz) throws IOException { if (!fetch()) { return -1; } sz = Math.min(sz, len-offset); System.arraycopy(buf,offset,b,off,sz); offset += sz; return sz; }
/** * Gets to the next chunk if we are done with the current one. * @return true if any data available * @throws IOException when i/o error */ private boolean fetch() throws IOException { if (closed) { throw new IOException("Stream already closed"); } if (current == null) { return false; } while(offset==len) { while(!part.parsed && current.next == null) { part.msg.makeProgress(); } current = current.next; if (current == null) { return false; } adjustInMemoryUsage(); this.offset = 0; this.buf = current.data.read(); this.len = current.data.size(); } return true; }
/** * Gets to the next chunk if we are done with the current one. * @return true if any data available * @throws IOException when i/o error */ private boolean fetch() throws IOException { if (closed) { throw new IOException("Stream already closed"); } if (current == null) { return false; } while(offset==len) { while(!part.parsed && current.next == null) { part.msg.makeProgress(); } current = current.next; if (current == null) { return false; } adjustInMemoryUsage(); this.offset = 0; this.buf = current.data.read(); this.len = current.data.size(); } return true; }
/** * Gets to the next chunk if we are done with the current one. * @return true if any data available * @throws IOException when i/o error */ private boolean fetch() throws IOException { if (closed) { throw new IOException("Stream already closed"); } if (current == null) { return false; } while(offset==len) { while(!part.parsed && current.next == null) { part.msg.makeProgress(); } current = current.next; if (current == null) { return false; } adjustInMemoryUsage(); this.offset = 0; this.buf = current.data.read(); this.len = current.data.size(); } return true; }
/** * Can get the attachment part's content multiple times. That means * the full content needs to be there in memory or on the file system. * Calling this method would trigger parsing for the part's data. So * do not call this unless it is required(otherwise, just wrap MIMEPart * into a object that returns InputStream for e.g DataHandler) * * @return data for the part's content */ public InputStream read() { if (readOnce) { throw new IllegalStateException("readOnce() is called before, read() cannot be called later."); } // Trigger parsing for the part while(tail == null) { if (!part.msg.makeProgress()) { throw new IllegalStateException("No such MIME Part: "+part); } } if (head == null) { throw new IllegalStateException("Already read. Probably readOnce() is called before."); } return new ReadMultiStream(); }
/** * Can get the attachment part's content multiple times. That means * the full content needs to be there in memory or on the file system. * Calling this method would trigger parsing for the part's data. So * do not call this unless it is required(otherwise, just wrap MIMEPart * into a object that returns InputStream for e.g DataHandler) * * @return data for the part's content */ public InputStream read() { if (readOnce) { throw new IllegalStateException("readOnce() is called before, read() cannot be called later."); } // Trigger parsing for the part while(tail == null) { if (!part.msg.makeProgress()) { throw new IllegalStateException("No such MIME Part: "+part); } } if (head == null) { throw new IllegalStateException("Already read. Probably readOnce() is called before."); } return new ReadMultiStream(); }
/** * Can get the attachment part's content multiple times. That means * the full content needs to be there in memory or on the file system. * Calling this method would trigger parsing for the part's data. So * do not call this unless it is required(otherwise, just wrap MIMEPart * into a object that returns InputStream for e.g DataHandler) * * @return data for the part's content */ public InputStream read() { if (readOnce) { throw new IllegalStateException("readOnce() is called before, read() cannot be called later."); } // Trigger parsing for the part while(tail == null) { if (!part.msg.makeProgress()) { throw new IllegalStateException("No such MIME Part: "+part); } } if (head == null) { throw new IllegalStateException("Already read. Probably readOnce() is called before."); } return new ReadMultiStream(); }
/** * Gets to the next chunk if we are done with the current one. * @return */ private boolean fetch() { if (current == null) { throw new IllegalStateException("Stream already closed"); } while(offset==len) { while(!part.parsed && current.next == null) { part.msg.makeProgress(); } current = current.next; if (current == null) { return false; } adjustInMemoryUsage(); this.offset = 0; this.buf = current.data.read(); this.len = current.data.size(); } return true; }
@Override public int read() throws IOException { if (!fetch()) { return -1; } return (buf[offset++] & 0xff); }
@Override public int read(byte b[], int off, int sz) throws IOException { if (!fetch()) { return -1; } sz = Math.min(sz, len-offset); System.arraycopy(buf,offset,b,off,sz); offset += sz; return sz; }
@Override public int read() throws IOException { if (!fetch()) { return -1; } return (buf[offset++] & 0xff); }
@Override public int read() throws IOException { if (!fetch()) { return -1; } return (buf[offset++] & 0xff); }
@Override public int read(byte b[], int off, int sz) throws IOException { if(!fetch()) return -1; sz = Math.min(sz, len-offset); System.arraycopy(buf,offset,b,off,sz); offset += sz; return sz; }
public int read() throws IOException { if (!fetch()) { return -1; } return (buf[offset++] & 0xff); }
@Override public int read(byte b[], int off, int sz) throws IOException { if (!fetch()) { return -1; } sz = Math.min(sz, len-offset); System.arraycopy(buf,offset,b,off,sz); offset += sz; return sz; }