FileDocCategorySizeDatePackage
IOUtils.javaAPI DocApache Poi 3.0.12039Mon Jan 01 12:39:42 GMT 2007org.apache.poi.util

IOUtils

public class IOUtils extends Object

Fields Summary
Constructors Summary
private IOUtils()

    
Methods Summary
public static intreadFully(java.io.InputStream in, byte[] b)
Helper method, just calls readFully(in, b, 0, b.length)

        return readFully(in, b, 0, b.length);
    
public static intreadFully(java.io.InputStream in, byte[] b, int off, int len)
Same as the normal in.read(b, off, len), but tries to ensure that the entire len number of bytes is read.

If the end of file is reached before any bytes are read, returns -1. Otherwise, returns the number of bytes read.

        int total = 0;
        for (;;) {
            int got = in.read(b, off + total, len - total);
            if (got < 0) {
                return (total == 0) ? -1 : total;
            } else {
                total += got;
                if (total == len)
                    return total;
            }
        }