ikrs.io
Class MultipartMIMETokenizer

java.lang.Object
  extended by ikrs.io.ByteSequenceTokenizer
      extended by ikrs.io.MultipartMIMETokenizer

public class MultipartMIMETokenizer
extends ByteSequenceTokenizer

The format of the multipart-body is: ------------------------------------ boundary := 0*69 bcharsnospace bchars := bcharsnospace / " " bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" / "+" / "_" / "," / "-" / "." / "/" / ":" / "=" / "?" --- with -------------------------- multipart-body := [preamble CRLF] dash-boundary transport-padding CRLF body-part *encapsulation close-delimiter transport-padding [CRLF epilogue] dash-boundary := "--" boundary encapsulation := delimiter transport-padding CRLF body-part delimiter := CRLF dash-boundary close-delimiter := delimiter "--" --- Example: ---------------------- --boundary 1. body-part --boundary 2. body-part --boundary 3. body-part --boundary-- (See http://stackoverflow.com/questions/4656287/what-rules-apply-to-mime-boundary) So to detect if the last boundary is reached we need to check if the next body-party begins with '--' CRLF This can only be done using a pushback input stream.


Field Summary
static int CR
           
static int LF
           
 
Constructor Summary
MultipartMIMETokenizer(java.io.InputStream in, java.lang.String boundary)
          Constructs a new multpiart-MIME tokenizer.
 
Method Summary
 java.io.InputStream getNextToken()
          The
static void main(java.lang.String[] argv)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CR

public static final int CR
See Also:
Constant Field Values

LF

public static final int LF
See Also:
Constant Field Values
Constructor Detail

MultipartMIMETokenizer

public MultipartMIMETokenizer(java.io.InputStream in,
                              java.lang.String boundary)
                       throws java.lang.NullPointerException
Constructs a new multpiart-MIME tokenizer.

Parameters:
in - The input stream to read from.
boundary - The boundary from the HTTP headers, WITHOUT the leading or trailing '--' respective CRLF!
Throws:
java.lang.NullPointerException
Method Detail

getNextToken

public java.io.InputStream getNextToken()
                                 throws java.io.IOException
The

Overrides:
getNextToken in class ByteSequenceTokenizer
Returns:
The next InputStream token from the underlying input stream.
Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] argv)