Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.io.EOFException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;

public class Main {
    public static int readFully(ReadableByteChannel paramReadableByteChannel, ByteBuffer paramByteBuffer,
            int paramInt) throws IOException {
        int i = 0;
        int j;
        do {
            j = paramReadableByteChannel.read(paramByteBuffer);
            if (-1 == j)
                break;
            i += j;
        } while (i != paramInt);
        if (j == -1)
            throw new EOFException("End of file. No more boxes.");
        return i;
    }

    public static void readFully(ReadableByteChannel paramReadableByteChannel, ByteBuffer paramByteBuffer)
            throws IOException {
        readFully(paramReadableByteChannel, paramByteBuffer, paramByteBuffer.remaining());
    }
}