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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InputStreamsedFilter(InputStream inStream, String sedScript) Just a wrapper that usesto process an input stream via theinvalid reference
#unixFilter(To, InputStream)sed command.static InputStreamsedFilter(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 InputStreamunixFilter(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
InputStreamto a Unix4j command and returns another input stream that is theoutputof 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 usesto process an input stream via theinvalid reference
#unixFilter(To, InputStream)sed 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
InputStreamin which the filtering operation is invoked dynamically while, the stream is read.
-