Skip to content

Wrap outputstream as well #114

Closed
Closed
@azachar

Description

Hi there!
A very nice tool!

Could you please add also support for output streams?

For instance the library I am using for datalake is providing only output stream, so what I did is this:

ProgressBar pb = new ProgressBarBuilder()
			    .setTaskName("Downloading "+pathItem.getName())
			    .setUnit("MiB", 1024*1024)
			    .build();
		
		pb.maxHint(pathItem.getContentLength());

OutputStream targetStream = new FileOutputStream(outputFile) {
			@Override
			public void write(byte[] b) throws IOException {
				super.write(b);
				pb.stepBy(b.length);
			}
			
			@Override
			public void write(int b) throws IOException {
				super.write(b);
				pb.step();
			}
			
			@Override
			public void write(byte[] b, int off, int len) throws IOException {
				super.write(b, off, len);
				pb.stepBy(b.length);
			}
		};

I guess that anonym class should be part of this project somehow.

Cheers,
Andrej

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions