Java Code Examples for com.sun.xml.internal.messaging.saaj.packaging.mime.util.LineInputStream#readLine()

The following examples show how to use com.sun.xml.internal.messaging.saaj.packaging.mime.util.LineInputStream#readLine() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InternetHeaders.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Read and parse the given RFC822 message stream till the
 * blank line separating the header from the body. Store the
 * header lines inside this InternetHeaders object. <p>
 * <p/>
 * Note that the header lines are added into this InternetHeaders
 * object, so any existing headers in this object will not be
 * affected.
 *
 * @param   is RFC822 input stream
 */
public void load(InputStream is) throws MessagingException {
    // Read header lines until a blank line. It is valid
    // to have BodyParts with no header lines.
    String line;
    LineInputStream lis = new LineInputStream(is);
    String prevline = null; // the previous header line, as a string
    // a buffer to accumulate the header in, when we know it's needed
    StringBuffer lineBuffer = new StringBuffer();

    try {
        //while ((line = lis.readLine()) != null) {
        do {
            line = lis.readLine();
            if (line != null &&
                    (line.startsWith(" ") || line.startsWith("\t"))) {
                // continuation of header
                if (prevline != null) {
                    lineBuffer.append(prevline);
                    prevline = null;
                }
                lineBuffer.append("\r\n");
                lineBuffer.append(line);
            } else {
                // new header
                if (prevline != null)
                    addHeaderLine(prevline);
                else if (lineBuffer.length() > 0) {
                    // store previous header first
                    addHeaderLine(lineBuffer.toString());
                    lineBuffer.setLength(0);
                }
                prevline = line;
            }
        } while (line != null && line.length() > 0);
    } catch (IOException ioex) {
        throw new MessagingException("Error in input stream", ioex);
    }
}
 
Example 2
Source File: InternetHeaders.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Read and parse the given RFC822 message stream till the
 * blank line separating the header from the body. Store the
 * header lines inside this InternetHeaders object. <p>
 * <p/>
 * Note that the header lines are added into this InternetHeaders
 * object, so any existing headers in this object will not be
 * affected.
 *
 * @param   is RFC822 input stream
 */
public void load(InputStream is) throws MessagingException {
    // Read header lines until a blank line. It is valid
    // to have BodyParts with no header lines.
    String line;
    LineInputStream lis = new LineInputStream(is);
    String prevline = null; // the previous header line, as a string
    // a buffer to accumulate the header in, when we know it's needed
    StringBuffer lineBuffer = new StringBuffer();

    try {
        //while ((line = lis.readLine()) != null) {
        do {
            line = lis.readLine();
            if (line != null &&
                    (line.startsWith(" ") || line.startsWith("\t"))) {
                // continuation of header
                if (prevline != null) {
                    lineBuffer.append(prevline);
                    prevline = null;
                }
                lineBuffer.append("\r\n");
                lineBuffer.append(line);
            } else {
                // new header
                if (prevline != null)
                    addHeaderLine(prevline);
                else if (lineBuffer.length() > 0) {
                    // store previous header first
                    addHeaderLine(lineBuffer.toString());
                    lineBuffer.setLength(0);
                }
                prevline = line;
            }
        } while (line != null && line.length() > 0);
    } catch (IOException ioex) {
        throw new MessagingException("Error in input stream", ioex);
    }
}
 
Example 3
Source File: InternetHeaders.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Read and parse the given RFC822 message stream till the
 * blank line separating the header from the body. Store the
 * header lines inside this InternetHeaders object. <p>
 * <p/>
 * Note that the header lines are added into this InternetHeaders
 * object, so any existing headers in this object will not be
 * affected.
 *
 * @param   is RFC822 input stream
 */
public void load(InputStream is) throws MessagingException {
    // Read header lines until a blank line. It is valid
    // to have BodyParts with no header lines.
    String line;
    LineInputStream lis = new LineInputStream(is);
    String prevline = null; // the previous header line, as a string
    // a buffer to accumulate the header in, when we know it's needed
    StringBuffer lineBuffer = new StringBuffer();

    try {
        //while ((line = lis.readLine()) != null) {
        do {
            line = lis.readLine();
            if (line != null &&
                    (line.startsWith(" ") || line.startsWith("\t"))) {
                // continuation of header
                if (prevline != null) {
                    lineBuffer.append(prevline);
                    prevline = null;
                }
                lineBuffer.append("\r\n");
                lineBuffer.append(line);
            } else {
                // new header
                if (prevline != null)
                    addHeaderLine(prevline);
                else if (lineBuffer.length() > 0) {
                    // store previous header first
                    addHeaderLine(lineBuffer.toString());
                    lineBuffer.setLength(0);
                }
                prevline = line;
            }
        } while (line != null && line.length() > 0);
    } catch (IOException ioex) {
        throw new MessagingException("Error in input stream", ioex);
    }
}
 
Example 4
Source File: InternetHeaders.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Read and parse the given RFC822 message stream till the
 * blank line separating the header from the body. Store the
 * header lines inside this InternetHeaders object. <p>
 * <p/>
 * Note that the header lines are added into this InternetHeaders
 * object, so any existing headers in this object will not be
 * affected.
 *
 * @param   is RFC822 input stream
 */
public void load(InputStream is) throws MessagingException {
    // Read header lines until a blank line. It is valid
    // to have BodyParts with no header lines.
    String line;
    LineInputStream lis = new LineInputStream(is);
    String prevline = null; // the previous header line, as a string
    // a buffer to accumulate the header in, when we know it's needed
    StringBuffer lineBuffer = new StringBuffer();

    try {
        //while ((line = lis.readLine()) != null) {
        do {
            line = lis.readLine();
            if (line != null &&
                    (line.startsWith(" ") || line.startsWith("\t"))) {
                // continuation of header
                if (prevline != null) {
                    lineBuffer.append(prevline);
                    prevline = null;
                }
                lineBuffer.append("\r\n");
                lineBuffer.append(line);
            } else {
                // new header
                if (prevline != null)
                    addHeaderLine(prevline);
                else if (lineBuffer.length() > 0) {
                    // store previous header first
                    addHeaderLine(lineBuffer.toString());
                    lineBuffer.setLength(0);
                }
                prevline = line;
            }
        } while (line != null && line.length() > 0);
    } catch (IOException ioex) {
        throw new MessagingException("Error in input stream", ioex);
    }
}
 
Example 5
Source File: InternetHeaders.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Read and parse the given RFC822 message stream till the
 * blank line separating the header from the body. Store the
 * header lines inside this InternetHeaders object.
 * <p>
 * Note that the header lines are added into this InternetHeaders
 * object, so any existing headers in this object will not be
 * affected.
 *
 * @param   is RFC822 input stream
 * @exception MessagingException in case of error
 */
public void load(InputStream is) throws MessagingException {
    // Read header lines until a blank line. It is valid
    // to have BodyParts with no header lines.
    String line;
    LineInputStream lis = new LineInputStream(is);
    String prevline = null; // the previous header line, as a string
    // a buffer to accumulate the header in, when we know it's needed
    StringBuilder lineBuffer = new StringBuilder();

    try {
        //while ((line = lis.readLine()) != null) {
        do {
            line = lis.readLine();
            if (line != null &&
                    (line.startsWith(" ") || line.startsWith("\t"))) {
                // continuation of header
                if (prevline != null) {
                    lineBuffer.append(prevline);
                    prevline = null;
                }
                lineBuffer.append("\r\n");
                lineBuffer.append(line);
            } else {
                // new header
                if (prevline != null)
                    addHeaderLine(prevline);
                else if (lineBuffer.length() > 0) {
                    // store previous header first
                    addHeaderLine(lineBuffer.toString());
                    lineBuffer.setLength(0);
                }
                prevline = line;
            }
        } while (line != null && line.length() > 0);
    } catch (IOException ioex) {
        throw new MessagingException("Error in input stream", ioex);
    }
}
 
Example 6
Source File: InternetHeaders.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Read and parse the given RFC822 message stream till the
 * blank line separating the header from the body. Store the
 * header lines inside this InternetHeaders object. <p>
 * <p/>
 * Note that the header lines are added into this InternetHeaders
 * object, so any existing headers in this object will not be
 * affected.
 *
 * @param   is RFC822 input stream
 */
public void load(InputStream is) throws MessagingException {
    // Read header lines until a blank line. It is valid
    // to have BodyParts with no header lines.
    String line;
    LineInputStream lis = new LineInputStream(is);
    String prevline = null; // the previous header line, as a string
    // a buffer to accumulate the header in, when we know it's needed
    StringBuffer lineBuffer = new StringBuffer();

    try {
        //while ((line = lis.readLine()) != null) {
        do {
            line = lis.readLine();
            if (line != null &&
                    (line.startsWith(" ") || line.startsWith("\t"))) {
                // continuation of header
                if (prevline != null) {
                    lineBuffer.append(prevline);
                    prevline = null;
                }
                lineBuffer.append("\r\n");
                lineBuffer.append(line);
            } else {
                // new header
                if (prevline != null)
                    addHeaderLine(prevline);
                else if (lineBuffer.length() > 0) {
                    // store previous header first
                    addHeaderLine(lineBuffer.toString());
                    lineBuffer.setLength(0);
                }
                prevline = line;
            }
        } while (line != null && line.length() > 0);
    } catch (IOException ioex) {
        throw new MessagingException("Error in input stream", ioex);
    }
}
 
Example 7
Source File: InternetHeaders.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Read and parse the given RFC822 message stream till the
 * blank line separating the header from the body. Store the
 * header lines inside this InternetHeaders object. <p>
 * <p/>
 * Note that the header lines are added into this InternetHeaders
 * object, so any existing headers in this object will not be
 * affected.
 *
 * @param   is RFC822 input stream
 */
public void load(InputStream is) throws MessagingException {
    // Read header lines until a blank line. It is valid
    // to have BodyParts with no header lines.
    String line;
    LineInputStream lis = new LineInputStream(is);
    String prevline = null; // the previous header line, as a string
    // a buffer to accumulate the header in, when we know it's needed
    StringBuffer lineBuffer = new StringBuffer();

    try {
        //while ((line = lis.readLine()) != null) {
        do {
            line = lis.readLine();
            if (line != null &&
                    (line.startsWith(" ") || line.startsWith("\t"))) {
                // continuation of header
                if (prevline != null) {
                    lineBuffer.append(prevline);
                    prevline = null;
                }
                lineBuffer.append("\r\n");
                lineBuffer.append(line);
            } else {
                // new header
                if (prevline != null)
                    addHeaderLine(prevline);
                else if (lineBuffer.length() > 0) {
                    // store previous header first
                    addHeaderLine(lineBuffer.toString());
                    lineBuffer.setLength(0);
                }
                prevline = line;
            }
        } while (line != null && line.length() > 0);
    } catch (IOException ioex) {
        throw new MessagingException("Error in input stream", ioex);
    }
}
 
Example 8
Source File: InternetHeaders.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Read and parse the given RFC822 message stream till the
 * blank line separating the header from the body. Store the
 * header lines inside this InternetHeaders object. <p>
 * <p/>
 * Note that the header lines are added into this InternetHeaders
 * object, so any existing headers in this object will not be
 * affected.
 *
 * @param   is RFC822 input stream
 */
public void load(InputStream is) throws MessagingException {
    // Read header lines until a blank line. It is valid
    // to have BodyParts with no header lines.
    String line;
    LineInputStream lis = new LineInputStream(is);
    String prevline = null; // the previous header line, as a string
    // a buffer to accumulate the header in, when we know it's needed
    StringBuffer lineBuffer = new StringBuffer();

    try {
        //while ((line = lis.readLine()) != null) {
        do {
            line = lis.readLine();
            if (line != null &&
                    (line.startsWith(" ") || line.startsWith("\t"))) {
                // continuation of header
                if (prevline != null) {
                    lineBuffer.append(prevline);
                    prevline = null;
                }
                lineBuffer.append("\r\n");
                lineBuffer.append(line);
            } else {
                // new header
                if (prevline != null)
                    addHeaderLine(prevline);
                else if (lineBuffer.length() > 0) {
                    // store previous header first
                    addHeaderLine(lineBuffer.toString());
                    lineBuffer.setLength(0);
                }
                prevline = line;
            }
        } while (line != null && line.length() > 0);
    } catch (IOException ioex) {
        throw new MessagingException("Error in input stream", ioex);
    }
}