Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap outputstream as well #114

Closed
azachar opened this issue Oct 6, 2021 · 6 comments
Closed

Wrap outputstream as well #114

azachar opened this issue Oct 6, 2021 · 6 comments

Comments

@azachar
Copy link

azachar commented Oct 6, 2021

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

@ctongfei
Copy link
Owner

ctongfei commented Oct 6, 2021

Thanks Andrej for the suggestion! I guess we should do OutputStream and Writer then?

@azachar
Copy link
Author

azachar commented Oct 7, 2021 via email

@ctongfei
Copy link
Owner

ctongfei commented Oct 7, 2021

@azachar what do you mean by a complete done?

@azachar
Copy link
Author

azachar commented Oct 8, 2021 via email

@ctongfei
Copy link
Owner

ctongfei commented Oct 8, 2021

Isn't pb.close() what you need?

@azachar
Copy link
Author

azachar commented Oct 8, 2021 via email

ctongfei added a commit that referenced this issue Jan 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants