microsoft-azure-storage/src/com/microsoft/azure/storage/table/MimeHelper.java
static ArrayList<MimePart> readBatchResponseStream(final InputStream inStream, final String expectedBundaryName,
            final OperationContext opContext, TablePayloadFormat format) throws IOException, StorageException {
        final ArrayList<MimePart> result = new ArrayList<MimePart>();
        final InputStreamReader streamReader = new InputStreamReader(inStream, Constants.UTF8_CHARSET);
        final BufferedReader reader = new BufferedReader(streamReader);
        final String mungedExpectedBoundaryName = "--".concat(expectedBundaryName);

        final MimeHeader docHeader = readMimeHeader(reader, opContext);
        if (docHeader.boundary == null || !docHeader.boundary.equals(mungedExpectedBoundaryName)) {
            throw generateMimeParseException();
        }

        MimeHeader currHeader = null;

        // No explicit changeset present
        if (docHeader.subBoundary == null) {
            do {
                result.add(readMimePart(reader, docHeader.boundary, opContext));
                currHeader = readMimeHeader(reader, opContext);
            } while (currHeader != null);
        }
        else {
            // explicit changeset present.
            currHeader = readMimeHeader(reader, opContext);
            if (currHeader == null) {
                throw generateMimeParseException();
            }
            else {
                do {
                    result.add(readMimePart(reader, docHeader.subBoundary, opContext));
                    currHeader = readMimeHeader(reader, opContext);
                } while (currHeader != null);
            }
        }

        return result;
    }
static ArrayList<MimePart> readBatchResponseStream(final InputStream inStream, final String expectedBundaryName,
            final OperationContext opContext, TablePayloadFormat format) throws IOException, StorageException {
        final ArrayList<MimePart> result = new ArrayList<MimePart>();
        final InputStreamReader streamReader = new InputStreamReader(inStream, Constants.UTF8_CHARSET);
        final BufferedReader reader = new BufferedReader(streamReader);
        final String mungedExpectedBoundaryName = "--".concat(expectedBundaryName);

        final MimeHeader docHeader = readMimeHeader(reader, opContext);
        if (docHeader.boundary == null || !docHeader.boundary.equals(mungedExpectedBoundaryName)) {
            throw generateMimeParseException();
        }

        MimeHeader currHeader = null;

        // No explicit changeset present
        if (docHeader.subBoundary == null) {
            do {
                result.add(readMimePart(reader, docHeader.boundary, opContext));
                currHeader = readMimeHeader(reader, opContext);
            } while (currHeader != null);
        }
        else {
            // explicit changeset present.
            currHeader = readMimeHeader(reader, opContext);
            if (currHeader == null) {
                throw generateMimeParseException();
            }
            else {
                do {
                    result.add(readMimePart(reader, docHeader.subBoundary, opContext));
                    currHeader = readMimeHeader(reader, opContext);
                } while (currHeader != null);
            }
        }

        return result;
    }
Reserved for internal use. Reads the response stream from a batch operation into an <code>ArrayList</code> of
{@link MimePart} objects.

@param inStream
An {@link InputStream} containing the operation response stream.
@param expectedBundaryName
A <code>String</code> containing the MIME part boundary string.
@param opContext
An {@link OperationContext} object for tracking the current operation. Specify <code>null</code> to
safely ignore operation context.
@param format
The {@link TablePayloadFormat} that will be used for parsing
@return
An <code>ArrayList</code> of {@link MimePart} objects parsed from the input stream.
@throws StorageException
if a storage service error occurs.
@throws IOException
if an error occurs while accessing the stream with Json.