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 c6d5414
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 = {
val stream = if (Files.isSameFile(path, Io.StdIn)) System.in else Files.newInputStream(path)
new BufferedInputStream(stream, 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 c6d5414

Please sign in to comment.