Example usage for javax.mail.internet SharedInputStream newStream

List of usage examples for javax.mail.internet SharedInputStream newStream

Introduction

In this page you can find the example usage for javax.mail.internet SharedInputStream newStream.

Prototype

public InputStream newStream(long start, long end);

Source Link

Document

Return a new InputStream representing a subset of the data from this InputStream, starting at start (inclusive) up to end (exclusive).

Usage

From source file:org.apache.james.mailbox.jpa.mail.model.openjpa.JPAEncryptedMailboxMessage.java

public JPAEncryptedMailboxMessage(JPAMailbox mailbox, Date internalDate, int size, Flags flags,
        SharedInputStream content, int bodyStartOctet, PropertyBuilder propertyBuilder)
        throws MailboxException {
    super(mailbox, internalDate, flags, size, bodyStartOctet, propertyBuilder);
    try {/*from  w  w w .  j a v a2 s  . c  o  m*/
        int headerEnd = bodyStartOctet;
        if (headerEnd < 0) {
            headerEnd = 0;
        }
        this.header = IOUtils.toByteArray(content.newStream(0, headerEnd));
        this.body = IOUtils.toByteArray(content.newStream(getBodyStartOctet(), -1));

    } catch (IOException e) {
        throw new MailboxException("Unable to parse message", e);
    }
}

From source file:org.apache.james.mailbox.jpa.mail.model.openjpa.JPAEncryptedMessage.java

public JPAEncryptedMessage(JPAMailbox mailbox, Date internalDate, int size, Flags flags,
        SharedInputStream content, int bodyStartOctet, final PropertyBuilder propertyBuilder)
        throws MailboxException {
    super(mailbox, internalDate, flags, size, bodyStartOctet, propertyBuilder);
    try {/*  w w  w  .j  a  v a 2 s  .c  om*/
        int headerEnd = bodyStartOctet;
        if (headerEnd < 0) {
            headerEnd = 0;
        }
        this.header = IOUtils.toByteArray(content.newStream(0, headerEnd));
        this.body = IOUtils.toByteArray(content.newStream(getBodyStartOctet(), -1));

    } catch (IOException e) {
        throw new MailboxException("Unable to parse message", e);
    }
}

From source file:org.apache.james.mailbox.jpa.mail.model.openjpa.JPAMailboxMessage.java

public JPAMailboxMessage(JPAMailbox mailbox, Date internalDate, int size, Flags flags,
        SharedInputStream content, int bodyStartOctet, PropertyBuilder propertyBuilder)
        throws MailboxException {
    super(mailbox, internalDate, flags, size, bodyStartOctet, propertyBuilder);
    try {//from w ww .j  a  va  2  s  . com
        int headerEnd = bodyStartOctet;
        if (headerEnd < 0) {
            headerEnd = 0;
        }
        this.header = IOUtils.toByteArray(content.newStream(0, headerEnd));
        this.body = IOUtils.toByteArray(content.newStream(getBodyStartOctet(), -1));

    } catch (IOException e) {
        throw new MailboxException("Unable to parse message", e);
    }
}

From source file:org.apache.james.mailbox.jpa.mail.model.openjpa.JPAMessage.java

public JPAMessage(JPAMailbox mailbox, Date internalDate, int size, Flags flags, SharedInputStream content,
        int bodyStartOctet, final PropertyBuilder propertyBuilder) throws MailboxException {
    super(mailbox, internalDate, flags, size, bodyStartOctet, propertyBuilder);
    try {//from w  w  w . j a  v a 2  s.c om
        int headerEnd = bodyStartOctet;
        if (headerEnd < 0) {
            headerEnd = 0;
        }
        this.header = IOUtils.toByteArray(content.newStream(0, headerEnd));
        this.body = IOUtils.toByteArray(content.newStream(getBodyStartOctet(), -1));

    } catch (IOException e) {
        throw new MailboxException("Unable to parse message", e);
    }
}