Package org.oddjob.io
Class CopyJob
java.lang.Object
org.oddjob.io.CopyJob
- All Implemented Interfaces:
Serializable,Runnable
- See Also:
- A file from one name to another.
- A file or files or directories to a different directory.
- An input (from another job) to a file.
- A file to an output.
- An input to an output.
- A file or input by lines to a Consumer such as a Bean Bus Destination
Description
A Copy job. Copy either:Example
Copy a file.
<oddjob id="this">
<job>
<copy to="${work.dir}">
<from>
<file file="${base.dir}/test/io/reference/test1.txt"/>
</from>
</copy>
</job>
</oddjob>
Copy a directory.
<oddjob id="this">
<job>
<copy to="${work.dir}">
<from>
<file file="${base.dir}/test/io/reference/a"/>
</from>
</copy>
</job>
</oddjob>
Copy from a file to a buffer.
<oddjob id="this">
<job>
<sequential>
<jobs>
<copy name="Copy from a file to a buffer">
<from>
<file file="${this.args[0]}/test/io/reference/test1.txt"/>
</from>
<output>
<identify id="buff">
<value>
<buffer/>
</value>
</identify>
</output>
</copy>
<echo id="e" name="What's in the file?">${buff}</echo>
</jobs>
</sequential>
</job>
</oddjob>
Copy into a Bean Bus. The lines from the file are copied into
the bus where they are mapped with a function that appends 'Foo' before writing
them out in another file.
<oddjob id="oddjob">
<job>
<sequential>
<jobs>
<properties>
<values>
<value key="work.dir" value="${java.io.tmpdir}"/>
</values>
</properties>
<bus:bus xmlns:bus="oddjob:beanbus">
<of>
<copy name="Copy from a file to lines">
<from>
<file file="${oddjob.dir}/files/Lines.txt"/>
</from>
</copy>
<bus:map>
<function>
<value value="#{function(x) { return x + 'Foo' }}"/>
</function>
</bus:map>
<bus:collect>
<output>
<file file="${work.dir}/LinesFoo.txt"/>
</output>
</bus:collect>
</of>
</bus:bus>
</jobs>
</sequential>
</job>
</oddjob>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintintFile[]getFrom()Get the from file.getInput()getName()Get the name.getTo()Get the to file.voidrun()voidsetConsumer(Consumer<? super String> consumer) voidSet the From file.voidsetInput(InputStream in) Set the InputStream.voidSet the namevoidsetOutput(OutputStream out) Set the OutputStream.voidSet the to file.toString()
-
Constructor Details
-
CopyJob
public CopyJob()
-
-
Method Details
-
getName
Get the name.- Returns:
- The name.
-
setName
Set the name- Parameters:
name- The name.
-
getFrom
Get the from file.- Returns:
- The from file.
-
setFrom
Set the From file.- Parameters:
file- The from file.
-
getTo
Get the to file.- Returns:
- The to file.
-
setTo
Set the to file.- Parameters:
file- The to file.
-
setInput
Set the InputStream.- Parameters:
in- The InputStream.
-
setOutput
Set the OutputStream.- Parameters:
out- The OutputStream.
-
getFilesCopied
public int getFilesCopied() -
getDirectoriesCopied
public int getDirectoriesCopied() -
run
public void run() -
getInput
- Returns:
- Returns the input.
-
getOutput
- Returns:
- Returns the output.
-
toString
-
setConsumer
-
getConsumer
-