Class ProcessPipeUtils
java.lang.Object
org.aksw.commons.io.process.pipe.ProcessPipeUtils
Utility functions to create file and input stream transform based on system calls
InputStreams passed as arguments to the various processors are considered to be owned by the
processors. Hence, the processors are in charge of closing them.
The client code is in charge of closing InputStreams returned by the processors.
TODO Enhance the FileCreation objects such that they expose a future for when
the process started modifying the file.
- Author:
- raven
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FileCreationcreateFileCreation(Process process, Path path) static Function<InputStream, InputStream> TODO Move this method elsewhere as it does not make use of a process Transformation using a piped input/outputstream createPipedTransform((in, out) -> { for(item : () -> readItems(in)) { write(item); } )static BiFunction<Path, Path, FileCreation> mapPathToPath(BiFunction<Path, Path, String[]> cmdBuilder) static PathToStreammapPathToStream(Function<Path, String[]> cmdBuilder) static BiFunction<InputStreamOrPath, Path, FileCreation> mapStreamToPath(Function<Path, String[]> cmdBuilder) static StreamToStreammapStreamToStream(String[] cmd) static ProcessstartProcess(ProcessBuilder processBuilder) static ThreadstartThreadedCopy(InputStream from, OutputStream to, Consumer<Exception> failureCallback) Create a new thread to copy from source to target TODO Closing the target silently terminate the thread and associated resources (such as a system process) Closing the input stream should not happen though as it is considered to be owned by the copy process
-
Constructor Details
-
ProcessPipeUtils
public ProcessPipeUtils()
-
-
Method Details
-
createPipedTransformer
public static Function<InputStream, InputStream> createPipedTransformer(BiConsumer<InputStream, OutputStream> action) TODO Move this method elsewhere as it does not make use of a process Transformation using a piped input/outputstream createPipedTransform((in, out) -> { for(item : () -> readItems(in)) { write(item); } )- Parameters:
action-- Returns:
-
startThreadedCopy
public static Thread startThreadedCopy(InputStream from, OutputStream to, Consumer<Exception> failureCallback) Create a new thread to copy from source to target TODO Closing the target silently terminate the thread and associated resources (such as a system process) Closing the input stream should not happen though as it is considered to be owned by the copy process- Parameters:
from-to-- Returns:
-
startProcess
-
mapPathToStream
-
createFileCreation
-
mapStreamToPath
public static BiFunction<InputStreamOrPath, Path, FileCreation> mapStreamToPath(Function<Path, String[]> cmdBuilder) -
mapPathToPath
public static BiFunction<Path, Path, FileCreation> mapPathToPath(BiFunction<Path, Path, String[]> cmdBuilder) -
mapStreamToStream
-