public InputStream getInputStream()

in src/main/org/apache/ant/compress/resources/SevenZResource.java [109:150]


    public InputStream getInputStream() throws IOException {
        if (isReference()) {
            return ((Resource) getCheckedRef()).getInputStream();
        }
        File f = getSevenZFile();
        if (f == null) {
            return super.getInputStream();
        }

        final SevenZFile z = new SevenZFile(f);
        SevenZArchiveEntry ze = z.getNextEntry();
        while (ze != null) {
            if (ze.getName().equals(getName())) {
                return new InputStream() {
                    @Override
                    public int read() throws IOException {
                        return z.read();
                    }
                    @Override
                    public int read(byte[] b) throws IOException {
                        return z.read(b);
                    }
                    @Override
                    public void close() throws IOException {
                        z.close();
                    }
                    @Override
                    protected void finalize() throws Throwable {
                        try {
                            close();
                        } finally {
                            super.finalize();
                        }
                    }
                };
            }
            ze = z.getNextEntry();
        }
        z.close();
        throw new BuildException("no entry " + getName() + " in "
                                 + getArchive());
    }