-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try to fix linux pdf opening again (#5945)
* Try to fix linux pdf opening again * execute stream gobbler in own task * add to other open method as well * use process builder and close reader
- Loading branch information
1 parent
93196ee
commit 5369b3b
Showing
2 changed files
with
52 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.jabref.gui.util; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.util.function.Consumer; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class StreamGobbler implements Runnable { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(StreamGobbler.class); | ||
|
||
private InputStream inputStream; | ||
private Consumer<String> consumer; | ||
|
||
public StreamGobbler(InputStream inputStream, Consumer<String> consumer) { | ||
this.inputStream = inputStream; | ||
this.consumer = consumer; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { | ||
reader.lines().forEach(consumer); | ||
} catch (IOException e) { | ||
LOGGER.error("Error when reading process stream from external application", e); | ||
} | ||
} | ||
} |