public InputStream getInputStream()

in src/main/org/apache/ant/compress/resources/DevZeroResource.java [35:52]


    public InputStream getInputStream() {
        final long size = getSize();
        return new InputStream() {
            private long bytesRead = 0;
            public int read() {
                return bytesRead++ < size ? 0 : -1;
            }
            public int read(byte[] b) {
                return read(b, 0, b.length);
            }
            public int read(byte[] b, int off, int len) {
                len = (int) Math.min((long) len, size - bytesRead);
                bytesRead += len;
                Arrays.fill(b, off, off + len, (byte) 0);
                return len == 0 ? -1 : len;
            }
        };
    }