Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jruby.runtime.load;
 

Author(s):
nicksieger
public class LoadServiceResourceInputStream extends ByteArrayInputStream {
    
Construct a LoadServiceResourceInputStream from the given bytes.

Parameters:
bytes the bytes to wrap in this stream
    public LoadServiceResourceInputStream(byte[] bytes) {
        super(bytes);
    }

    
Construct a new LoadServiceInputStream by reading all bytes from the specified stream. You are responsible for the lifecycle of the given stream after this constructor has been called (i.e. it will not be closed for you).

Parameters:
stream the stream from which to read bytes
Throws:
java.io.IOException if the reading causes an IOException
    public LoadServiceResourceInputStream(InputStream streamthrows IOException {
        super(new byte[0]);
        bufferEntireStream(stream);
    }
    public byte[] getBytes() {
        if (. != ) {
            byte[] b = new byte[];
            System.arraycopy(, 0, b, 0, );
            return b;
        } else {
            return ;
        }
    }
    private void bufferEntireStream(InputStream streamthrows IOException {
        byte[] b = new byte[1024];
        int bytesRead = 0;
        while ((bytesRead = stream.read(b)) != -1) {
            byte[] newbuf = new byte[. + bytesRead];
            System.arraycopy(, 0, newbuf, 0, .);
            System.arraycopy(b, 0, newbuf.bytesRead);
             = newbuf;
             = .;
        }
    }
New to GrepCode? Check out our FAQ X