Here you can find the source of base64ReadChunk(InputStream in, byte[] chunk)
private static boolean base64ReadChunk(InputStream in, byte[] chunk) throws IOException
//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."); } } }