Skip to content

Commit

Permalink
Workaround for Files.newInputStream() returning a stream that's incom…
Browse files Browse the repository at this point in the history
…patible with stdin.
  • Loading branch information
tfenne committed Nov 3, 2018
1 parent 689807f commit 8397463
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/scala/com/fulcrumgenomics/commons/io/Io.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ trait IoUtil {
def bufferSize: Int = 32 * 1024

/** Creates a new InputStream to read from the supplied path. */
def toInputStream(path: Path) : InputStream = new BufferedInputStream(Files.newInputStream(path), bufferSize)
def toInputStream(path: Path) : InputStream = {
if (Files.isSameFile(path, Io.StdIn)) System.in
else new BufferedInputStream(Files.newInputStream(path), bufferSize)
}

/** Creates a new BufferedReader to read from the supplied path. */
def toOutputStream(path: Path) : OutputStream = new BufferedOutputStream(Files.newOutputStream(path), bufferSize)
Expand Down

0 comments on commit 8397463

Please sign in to comment.