class DeferredFileBufferingInputStream extends ProxyInputStream {

    @Override
    public void close() throws IOException {
        if (!closed) {
            // Close any previously open stream buffer
            this.in.close();

            // Delete tmp file
            if (this.tmpFile != null) {
                Files.delete(this.tmpFile.toPath());
            }
            closed = true;
        }
    }

    public  DeferredFileBufferingInputStream(InputStream sourceInputStream, long sourceSize, int maxInMemoryBufferSize,
        File tmpDirectory);

}