You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ha...@apache.org on 2012/06/29 19:48:22 UTC
svn commit: r1355485 -
/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
Author: hadrian
Date: Fri Jun 29 17:48:20 2012
New Revision: 1355485
URL: http://svn.apache.org/viewvc?rev=1355485&view=rev
Log:
Refactor method to remove unused and overwritten in argument
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java?rev=1355485&r1=1355484&r2=1355485&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileOperations.java Fri Jun 29 17:48:20 2012
@@ -275,7 +275,7 @@ public class FileOperations implements G
FileChannel in = new FileInputStream(source).getChannel();
FileChannel out = null;
try {
- out = prepareOutputFileChannel(target, out);
+ out = prepareOutputFileChannel(target);
LOG.debug("Using FileChannel to write file: {}", target);
long size = in.size();
long position = 0;
@@ -293,7 +293,7 @@ public class FileOperations implements G
private void writeFileByStream(InputStream in, File target) throws IOException {
FileChannel out = null;
try {
- out = prepareOutputFileChannel(target, out);
+ out = prepareOutputFileChannel(target);
LOG.debug("Using InputStream to write file: {}", target);
int size = endpoint.getBufferSize();
byte[] buffer = new byte[size];
@@ -331,14 +331,11 @@ public class FileOperations implements G
* Creates and prepares the output file channel. Will position itself in correct position if the file is writable
* eg. it should append or override any existing content.
*/
- private FileChannel prepareOutputFileChannel(File target, FileChannel out) throws IOException {
+ private FileChannel prepareOutputFileChannel(File target) throws IOException {
if (endpoint.getFileExist() == GenericFileExist.Append) {
- out = new RandomAccessFile(target, "rw").getChannel();
- out = out.position(out.size());
- } else {
- // will override
- out = new FileOutputStream(target).getChannel();
+ FileChannel out = new RandomAccessFile(target, "rw").getChannel();
+ return out.position(out.size());
}
- return out;
+ return new FileOutputStream(target).getChannel();
}
}