Example usage for org.apache.wicket.util.io ByteArrayOutputStream write

List of usage examples for org.apache.wicket.util.io ByteArrayOutputStream write

Introduction

In this page you can find the example usage for org.apache.wicket.util.io ByteArrayOutputStream write.

Prototype

@Override
public synchronized void write(final byte[] b, final int off, final int len) 

Source Link

Usage

From source file:com.gitblit.servlet.PtServlet.java

License:Apache License

byte[] readAll(InputStream is) {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    try {//  ww  w.  j a  va  2 s . c o m
        byte[] buffer = new byte[4096];
        int len = 0;
        while ((len = is.read(buffer)) > -1) {
            os.write(buffer, 0, len);
        }
        return os.toByteArray();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            os.close();
            is.close();
        } catch (Exception e) {
            // ignore
        }
    }
    return new byte[0];
}