protected InputStream getContentStream()
					throws MessagingException {
	try {
	synchronized(this) {
	    if (contentStream == null) {
		InputStream rawcontent = folder.getProtocol().retr(msgnum,
					msgSize > 0 ? msgSize + hdrSize : 0);
		if (rawcontent == null) {
		    expunged = true;
		    throw new MessageRemovedException();    //  XXX - what else?
		}
		if (headers == null ||
			((POP3Store)(folder.getStore())).forgetTopHeaders) {
		    headers = new InternetHeaders(rawcontent);
		    hdrSize =
			(int)((SharedInputStream)rawcontent).getPosition();
		} else {
		    /*
		     * Already have the headers, have to skip the headers
		     * in the content array and return the body.
		     *
		     * XXX - It seems that some mail servers return slightly
		     * different headers in the RETR results than were returned
		     * in the TOP results, so we can't depend on remembering
		     * the size of the headers from the TOP command and just
		     * skipping that many bytes.  Instead, we have to process
		     * the content, skipping over the header until we come to
		     * the empty line that separates the header from the body.
		     */
		    int offset = 0;
		    for (;;) {
			int len = 0;	// number of bytes in this line
			int c1;
			while ((c1 = rawcontent.read()) >= 0) {
			    if (c1 == '\n')	// end of line
				break;
			    else if (c1 == '\r') {
				// got CR, is the next char LF?
				if (rawcontent.available() > 0) {
				    rawcontent.mark(1);
				    if (rawcontent.read() != '\n')
					rawcontent.reset();
				}
				break;	// in any case, end of line
			    }
			    // not CR, NL, or CRLF, count the byte
			    len++;
			}
			// here when end of line or out of data
			// if out of data, we're done
			if (rawcontent.available() == 0)
			    break;
			// if it was an empty line, we're done
			if (len == 0)
			    break;
		    }
		    hdrSize =
			(int)((SharedInputStream)rawcontent).getPosition();
		}
		contentStream =
		    ((SharedInputStream)rawcontent).newStream(hdrSize, -1);
		rawcontent = null;	// help GC
	    }
	}
	} catch (EOFException eex) {
	    folder.close(false);
	    throw new FolderClosedException(folder, eex.toString());
	} catch (IOException ex) {
	    throw new MessagingException("error fetching POP3 content", ex);
	}
	return super.getContentStream();
    }
protected InputStream getContentStream()
					throws MessagingException {
	try {
	synchronized(this) {
	    if (contentStream == null) {
		InputStream rawcontent = folder.getProtocol().retr(msgnum,
					msgSize > 0 ? msgSize + hdrSize : 0);
		if (rawcontent == null) {
		    expunged = true;
		    throw new MessageRemovedException();   
		}
		if (headers == null ||
			((POP3Store)(folder.getStore())).forgetTopHeaders) {
		    headers = new InternetHeaders(rawcontent);
		    hdrSize =
			(int)((SharedInputStream)rawcontent).getPosition();
		} else {
		   
		    int offset = 0;
		    for (;;) {
			int len = 0;
			int c1;
			while ((c1 = rawcontent.read()) >= 0) {
			    if (c1 == '\n')
				break;
			    else if (c1 == '\r') {
			
				if (rawcontent.available() > 0) {
				    rawcontent.mark(1);
				    if (rawcontent.read() != '\n')
					rawcontent.reset();
				}
				break;
			    }
			   
			    len++;
			}
		
		
			if (rawcontent.available() == 0)
			    break;
		
			if (len == 0)
			    break;
		    }
		    hdrSize =
			(int)((SharedInputStream)rawcontent).getPosition();
		}
		contentStream =
		    ((SharedInputStream)rawcontent).newStream(hdrSize, -1);
		rawcontent = null;
	    }
	}
	} catch (EOFException eex) {
	    folder.close(false);
	    throw new FolderClosedException(folder, eex.toString());
	} catch (IOException ex) {
	    throw new MessagingException("error fetching POP3 content", ex);
	}
	return super.getContentStream();
    }
protected inputstream getcontentstream() throws messagingexception { try { synchronized(this) { if (contentstream == null) { inputstream rawcontent = folder.getprotocol().retr(msgnum, msgsize > 0 ? msgsize + hdrsize : 0); if (rawcontent == null) { expunged = true; throw new messageremovedexception(); } if (headers == null || ((pop3store)(folder.getstore())).forgettopheaders) { headers = new internetheaders(rawcontent); hdrsize = (int)((sharedinputstream)rawcontent).getposition(); } else { int offset = 0; for (;;) { int len = 0; int c1; while ((c1 = rawcontent.read()) >= 0) { if (c1 == '\n') break; else if (c1 == '\r') { if (rawcontent.available() > 0) { rawcontent.mark(1); if (rawcontent.read() != '\n') rawcontent.reset(); } break; } len++; } if (rawcontent.available() == 0) break; if (len == 0) break; } hdrsize = (int)((sharedinputstream)rawcontent).getposition(); } contentstream = ((sharedinputstream)rawcontent).newstream(hdrsize, -1); rawcontent = null; } } } catch (eofexception eex) { folder.close(false); throw new folderclosedexception(folder, eex.tostring()); } catch (ioexception ex) { throw new messagingexception("error fetching pop3 content", ex); } return super.getcontentstream(); }