Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Classe che consuma un InputStream
- //Adattato da https://www.baeldung.com/run-shell-command-in-java
- import java.io.BufferedReader;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.util.function.Consumer;
- public class Divoratore implements Runnable {
- private InputStream inputStream;
- private Consumer<String> consumatore;
- public Divoratore(InputStream inputStream, Consumer<String> consumer) {
- this.inputStream = inputStream;
- this.consumatore = consumer;
- }
- @Override
- public void run() {
- new BufferedReader(new InputStreamReader(inputStream)).lines().forEach(consumatore);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement