Java Base64 base64ReadChunk(InputStream in, byte[] chunk)

Here you can find the source of base64ReadChunk(InputStream in, byte[] chunk)

Description

Fully reads a chunk of data from an IO stream.

License

Open Source License

Declaration

private static boolean base64ReadChunk(InputStream in, byte[] chunk)
        throws IOException 

Method Source Code

//package com.java2s;
/*/*  ww  w.j a va  2 s  .c om*/
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
 * which accompanies this distribution, and is available
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
 * Initial Contributors:
 * Nokia Corporation - initial contribution.
 *
 * Contributors:
 *
 * Description: 
 *
 */

import java.io.IOException;

import java.io.InputStream;

public class Main {
    /**
     * Fully reads a chunk of data from an IO stream.
     * Returns <code>true</code> if the chunk of data has been read, or
     * <code>false</code> if end of file has been reached.
     *
     * This code does not handle empty characters in the middle of
     * BASE64 stream which is OK for the purposes of XRPC.
     *
     * @exception IOException of end of file has been reached before
     * the chunk od data has been fully read
     */
    private static boolean base64ReadChunk(InputStream in, byte[] chunk)
            throws IOException {
        int count = in.read(chunk);
        if (count < 0) {
            return false; // normal end of file condition
        } else if (count == chunk.length) {
            return true; // got the whole chunk in one shot
        } else {
            throw new IOException(
                    "BASE64Decoder: Not enough bytes for an atom.");
        }
    }
}

Related

  1. base64Append(StringBuilder sb, int digit, boolean haveNonZero)
  2. base64Character(int number)
  3. base64CharToValue(byte c)
  4. base64enc(byte[] in)
  5. base64Pad(String s)
  6. base64ToBits(char data)
  7. base64ToByteArray(String s)
  8. base64ToBytes(final String base64)
  9. base64ToBytes(String value)