Class Unix4jUtils
Utilities for the great Unix4j library.
WARNING: In order to avoid too many dependency for jUtils, you have to declare the dependency on both Unix4j and EasyStream (copy-paste them from the junit-io's pom).
- Author:
- brandizi
- Date:
- 22 Mar 2018
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic InputStream
sedFilter
(InputStream inStream, String sedScript) Just a wrapper that uses#unixFilter(To, InputStream)
to process an input stream via thesed command
.static InputStream
sedFilter
(InputStream inStream, String regex, String repl) Just a wrapper ofsedFilter(InputStream, String)
that tweaks a stream dynamically, to replace text based on a regular expression.static InputStream
unixFilter
(org.unix4j.builder.To command) Pipes the output of a Unix4j command
-
Constructor Details
-
Unix4jUtils
public Unix4jUtils()
-
-
Method Details
-
unixFilter
Pipes the output of a Unix4j command
This sends an
InputStream
to a Unix4j command and returns another input stream that is theoutput
of that command.Differently from
Command.join(Command)
, this emulates the pipe '|' operator in Unix in a way such that the command's output can be sent to some Java input consumer, after it has been filtered by the command.Also note that we're doing this dynamically, the initial input stream is processed while a consumer reads the stream returned by this method. This is achieved through the EasyStream library
-
sedFilter
Just a wrapper that uses#unixFilter(To, InputStream)
to process an input stream via thesed command
. -
sedFilter
Just a wrapper ofsedFilter(InputStream, String)
that tweaks a stream dynamically, to replace text based on a regular expression. The repl parameter accepts backreferences like\1
.- Returns:
- the filter that does the replacement, as an
InputStream
in which the filtering operation is invoked dynamically while, the stream is read.
-