Author: davsclaus Date: Sun Jul 26 07:43:34 2009 New Revision: 797872 URL: http://svn.apache.org/viewvc?rev=797872&view=rev Log: CAMEL-1849: Polished code a bit.
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java camel/trunk/camel-core/src/main/java/org/apache/camel/util/IOHelper.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java?rev=797872&r1=797871&r2=797872&view=diff ============================================================================== --- camel/trunk/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/converter/stream/CachedOutputStream.java Sun Jul 26 07:43:34 2009 @@ -26,7 +26,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -40,7 +39,7 @@ * This output stream will store the content into a File if the stream context size is exceed the * THRESHOLD which's default value is 64K. The temp file will store in the temp directory, you * can configure it by setting the TEMP_DIR property. If you don't set the TEMP_DIR property, - * it will choice the directory which is set by the system property of "java.io.tmpdir". + * it will choose the directory which is set by the system property of "java.io.tmpdir". * You can get a cached input stream of this stream. The temp file which is created with this * output stream will be deleted when you close this output stream or the cached inputStream. */ Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/IOHelper.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IOHelper.java?rev=797872&r1=797871&r2=797872&view=diff ============================================================================== --- camel/trunk/camel-core/src/main/java/org/apache/camel/util/IOHelper.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/IOHelper.java Sun Jul 26 07:43:34 2009 @@ -30,7 +30,7 @@ public final class IOHelper { private static final int DEFAULT_BUFFER_SIZE = 1024 * 4; - private static final Charset UTF8_CHARSET = Charset.forName("utf-8"); + private static final Charset UTF8_CHARSET = Charset.forName("UTF-8"); private IOHelper() { //Utility Class @@ -81,8 +81,7 @@ return copy(input, output, DEFAULT_BUFFER_SIZE); } - public static int copy(final InputStream input, final OutputStream output, int bufferSize) - throws IOException { + public static int copy(final InputStream input, final OutputStream output, int bufferSize) throws IOException { int avail = input.available(); if (avail > 262144) { avail = 262144; @@ -90,9 +89,9 @@ if (avail > bufferSize) { bufferSize = avail; } + final byte[] buffer = new byte[bufferSize]; - int n = 0; - n = input.read(buffer); + int n = input.read(buffer); int total = 0; while (-1 != n) { output.write(buffer, 0, n); @@ -110,5 +109,6 @@ public static void copyAndCloseInput(InputStream input, OutputStream output, int bufferSize) throws IOException { copy(input, output, bufferSize); + input.close(); } }