You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2013/05/17 17:24:14 UTC

svn commit: r1483859 - in /commons/proper/io/trunk/src: changes/changes.xml main/java/org/apache/commons/io/IOUtils.java test/java/org/apache/commons/io/IOUtilsTestCase.java

Author: sebb
Date: Fri May 17 15:24:13 2013
New Revision: 1483859

URL: http://svn.apache.org/r1483859
Log:
IO-233 IO-330 Add Methods for Buffering Streams/Writers To IOUtils

Modified:
    commons/proper/io/trunk/src/changes/changes.xml
    commons/proper/io/trunk/src/main/java/org/apache/commons/io/IOUtils.java
    commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsTestCase.java

Modified: commons/proper/io/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/changes/changes.xml?rev=1483859&r1=1483858&r2=1483859&view=diff
==============================================================================
--- commons/proper/io/trunk/src/changes/changes.xml (original)
+++ commons/proper/io/trunk/src/changes/changes.xml Fri May 17 15:24:13 2013
@@ -47,6 +47,14 @@ The <action> type attribute can be add,u
   <body>
     <!-- The release date is the date RC is cut -->
     <release version="2.5" date="2013-??-??" description="New features and bug fixes.">    
+      <action issue="IO-233" dev="sebb" type="add">
+         Add Methods for Buffering Streams/Writers To IOUtils
+         Added overloaded buffer() methods - see also IO-330
+      </action>
+      <action issue="IO-330" dev="sebb" type="add">
+         IOUtils#toBufferedOutputStream/toBufferedWriter to conditionally wrap the output
+         Added overloaded buffer() methods - see also IO-233 
+      </action>
       <action issue="IO-381" dev="ggregory" type="add">
         Add FileUtils.copyInputStreamToFile API with option to leave the source open.
         See copyInputStreamToFile(final InputStream source, final File destination, boolean closeSource)
@@ -74,10 +82,6 @@ The <action> type attribute can be add,u
         FileUtils.listFilesAndDirs includes original dir in results even when it doesn't match filter
         Javadoc: clarify that original dir is included in the results
       </action>            
-      <action issue="IO-330" dev="sebb" type="add">
-         IOUtils#toBufferedOutputStream/toBufferedWriter to conditionally wrap the output
-         Added asBufferedInputStream, asBufferedOutputStream, asBufferedReader, asBufferedWriter 
-      </action>
       <action issue="IO-346" dev="sebb" type="add">
          Add ByteArrayOutputStream.toInputStream()
       </action>

Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/IOUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/IOUtils.java?rev=1483859&r1=1483858&r2=1483859&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/IOUtils.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/IOUtils.java Fri May 17 15:24:13 2013
@@ -443,7 +443,7 @@ public class IOUtils {
      *            the reader to wrap or return (not null)
      * @return the given reader or a new {@link BufferedReader} for the given reader
      * @since 2.2
-     * @see #asBufferedReader(Reader)
+     * @see #buffer(Reader)
      * @throws NullPointerException if the input parameter is null
      */
     public static BufferedReader toBufferedReader(final Reader reader) {
@@ -460,7 +460,7 @@ public class IOUtils {
      * @since 2.5
      * @throws NullPointerException if the input parameter is null
      */
-    public static BufferedReader asBufferedReader(final Reader reader) {
+    public static BufferedReader buffer(final Reader reader) {
         return reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader);
     }
 
@@ -474,7 +474,7 @@ public class IOUtils {
      * @since 2.5
      * @throws NullPointerException if the input parameter is null
      */
-    public static BufferedWriter asBufferedWriter(final Writer writer) {
+    public static BufferedWriter buffer(final Writer writer) {
         return writer instanceof BufferedWriter ? (BufferedWriter) writer : new BufferedWriter(writer);
     }
 
@@ -488,7 +488,7 @@ public class IOUtils {
      * @since 2.5
      * @throws NullPointerException if the input parameter is null
      */
-    public static BufferedOutputStream asBufferedOutputStream(final OutputStream outputStream) {
+    public static BufferedOutputStream buffer(final OutputStream outputStream) {
         // reject null early on rather than waiting for IO operation to fail
         if (outputStream == null) { // not checked by BufferedOutputStream
             throw new NullPointerException();
@@ -506,7 +506,7 @@ public class IOUtils {
      * @since 2.5
      * @throws NullPointerException if the input parameter is null
      */
-    public static BufferedInputStream asBufferedInputStream(final InputStream inputStream) {
+    public static BufferedInputStream buffer(final InputStream inputStream) {
         // reject null early on rather than waiting for IO operation to fail
         if (inputStream == null) { // not checked by BufferedInputStream
             throw new NullPointerException();

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsTestCase.java?rev=1483859&r1=1483858&r2=1483859&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsTestCase.java (original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsTestCase.java Fri May 17 15:24:13 2013
@@ -1212,25 +1212,25 @@ public class IOUtilsTestCase extends Fil
 
     public void testAsBufferedNull() {
         try {
-            IOUtils.asBufferedInputStream(null);
+            IOUtils.buffer((InputStream) null);
             fail("Expected NullPointerException");
         } catch (NullPointerException npe) {
             // expected
         }
         try {
-            IOUtils.asBufferedOutputStream(null);
+            IOUtils.buffer((OutputStream) null);
             fail("Expected NullPointerException");
         } catch (NullPointerException npe) {
             // expected
         }
         try {
-            IOUtils.asBufferedReader(null);
+            IOUtils.buffer((Reader) null);
             fail("Expected NullPointerException");
         } catch (NullPointerException npe) {
             // expected
         }
         try {
-            IOUtils.asBufferedWriter(null);
+            IOUtils.buffer((Writer) null);
             fail("Expected NullPointerException");
         } catch (NullPointerException npe) {
             // expected
@@ -1244,9 +1244,9 @@ public class IOUtilsTestCase extends Fil
                 return 0;
             }
         };
-        final BufferedInputStream bis = IOUtils.asBufferedInputStream(is);
+        final BufferedInputStream bis = IOUtils.buffer(is);
         assertNotSame(is, bis);
-        assertSame(bis, IOUtils.asBufferedInputStream(bis));
+        assertSame(bis, IOUtils.buffer(bis));
     }
 
     public void testAsBufferedOutputStream() {
@@ -1254,9 +1254,9 @@ public class IOUtilsTestCase extends Fil
             @Override
             public void write(int b) throws IOException { }
         };
-        final BufferedOutputStream bis = IOUtils.asBufferedOutputStream(is);
+        final BufferedOutputStream bis = IOUtils.buffer(is);
         assertNotSame(is, bis);
-        assertSame(bis, IOUtils.asBufferedOutputStream(bis));
+        assertSame(bis, IOUtils.buffer(bis));
     }
 
     public void testAsBufferedReader() {
@@ -1268,9 +1268,9 @@ public class IOUtilsTestCase extends Fil
             @Override
             public void close() throws IOException { }
         };
-        final BufferedReader bis = IOUtils.asBufferedReader(is);
+        final BufferedReader bis = IOUtils.buffer(is);
         assertNotSame(is, bis);
-        assertSame(bis, IOUtils.asBufferedReader(bis));
+        assertSame(bis, IOUtils.buffer(bis));
     }
 
     public void testAsBufferedWriter() {
@@ -1287,8 +1287,8 @@ public class IOUtilsTestCase extends Fil
             @Override
             public void close() throws IOException { }
         };
-        final BufferedWriter bis = IOUtils.asBufferedWriter(is);
+        final BufferedWriter bis = IOUtils.buffer(is);
         assertNotSame(is, bis);
-        assertSame(bis, IOUtils.asBufferedWriter(bis));
+        assertSame(bis, IOUtils.buffer(bis));
     }
 }