FileDocCategorySizeDatePackage
IOUtils.javaAPI DocApache Axis 1.41909Sat Apr 22 18:57:26 BST 2006org.apache.axis.utils

IOUtils

public class IOUtils extends Object
Utility class containing IO helper methods

Fields Summary
Constructors Summary
private IOUtils()

    
Methods Summary
public static intreadFully(java.io.InputStream in, byte[] b)
Read into a byte array; tries to ensure that the the full buffer is read. Helper method, just calls readFully(in, b, 0, b.length)

see
#readFully(java.io.InputStream, byte[], int, int)

        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.

returns
the number of bytes read, or -1 if the end of file is reached before any bytes are 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;
            }
        }