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/04/17 18:38:57 UTC

svn commit: r1468992 - in /commons/proper/io/trunk/src/main/java/org/apache/commons/io: ./ input/ output/

Author: sebb
Date: Wed Apr 17 16:38:56 2013
New Revision: 1468992

URL: http://svn.apache.org/r1468992
Log:
IO-314 Deprecate all methods that use the default encoding

Modified:
    commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java
    commons/proper/io/trunk/src/main/java/org/apache/commons/io/IOUtils.java
    commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReaderInputStream.java
    commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java
    commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java
    commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/LockableFileWriter.java
    commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/WriterOutputStream.java

Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java?rev=1468992&r1=1468991&r2=1468992&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java Wed Apr 17 16:38:56 2013
@@ -1744,7 +1744,9 @@ public class FileUtils {
      * @return the file contents, never {@code null}
      * @throws IOException in case of an I/O error
      * @since 1.3.1
+     * @deprecated 2.5 use {@link #readFileToString(File, Charset)} instead
      */
+    @Deprecated
     public static String readFileToString(final File file) throws IOException {
         return readFileToString(file, Charset.defaultCharset());
     }
@@ -1815,7 +1817,9 @@ public class FileUtils {
      * @return the list of Strings representing each line in the file, never {@code null}
      * @throws IOException in case of an I/O error
      * @since 1.3
+     * @deprecated 2.5 use {@link #readLines(File, Charset)} instead
      */
+    @Deprecated
     public static List<String> readLines(final File file) throws IOException {
         return readLines(file, Charset.defaultCharset());
     }
@@ -1958,7 +1962,9 @@ public class FileUtils {
      * @param file  the file to write
      * @param data  the content to write to the file
      * @throws IOException in case of an I/O error
+     * @deprecated 2.5 use {@link #writeStringToFile(File, String, Charset)} instead
      */
+    @Deprecated
     public static void writeStringToFile(final File file, final String data) throws IOException {
         writeStringToFile(file, data, Charset.defaultCharset(), false);
     }
@@ -1972,7 +1978,9 @@ public class FileUtils {
      * end of the file rather than overwriting
      * @throws IOException in case of an I/O error
      * @since 2.1
+     * @deprecated 2.5 use {@link #writeStringToFile(File, String, Charset, boolean)} instead
      */
+    @Deprecated
     public static void writeStringToFile(final File file, final String data, final boolean append) throws IOException {
         writeStringToFile(file, data, Charset.defaultCharset(), append);
     }
@@ -1984,7 +1992,9 @@ public class FileUtils {
      * @param data  the content to write to the file
      * @throws IOException in case of an I/O error
      * @since 2.0
+     * @deprecated 2.5 use {@link #write(File, CharSequence, Charset)} instead
      */
+    @Deprecated
     public static void write(final File file, final CharSequence data) throws IOException {
         write(file, data, Charset.defaultCharset(), false);
     }
@@ -1998,7 +2008,9 @@ public class FileUtils {
      * end of the file rather than overwriting
      * @throws IOException in case of an I/O error
      * @since 2.1
+     * @deprecated 2.5 use {@link #write(File, CharSequence, Charset, boolean)} instead
      */
+    @Deprecated
     public static void write(final File file, final CharSequence data, final boolean append) throws IOException {
         write(file, data, Charset.defaultCharset(), append);
     }

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=1468992&r1=1468991&r2=1468992&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 Wed Apr 17 16:38:56 2013
@@ -537,7 +537,9 @@ public class IOUtils {
      * @return the requested byte array
      * @throws NullPointerException if the input is null
      * @throws IOException if an I/O error occurs
+     * @deprecated 2.5 use {@link #toByteArray(Reader, Charset)} instead
      */
+    @Deprecated
     public static byte[] toByteArray(final Reader input) throws IOException {
         return toByteArray(input, Charset.defaultCharset());
     }
@@ -596,7 +598,7 @@ public class IOUtils {
      * @return the requested byte array
      * @throws NullPointerException if the input is null
      * @throws IOException if an I/O error occurs (never occurs)
-     * @deprecated Use {@link String#getBytes()}
+     * @deprecated 2.5 Use {@link String#getBytes()} instead
      */
     @Deprecated
     public static byte[] toByteArray(final String input) throws IOException {
@@ -676,7 +678,9 @@ public class IOUtils {
      * @throws NullPointerException if the input is null
      * @throws IOException if an I/O error occurs
      * @since 1.1
+     * @deprecated 2.5 use {@link #toCharArray(InputStream, Charset)} instead
      */
+    @Deprecated
     public static char[] toCharArray(final InputStream is) throws IOException {
         return toCharArray(is, Charset.defaultCharset());
     }
@@ -757,7 +761,9 @@ public class IOUtils {
      * @return the requested String
      * @throws NullPointerException if the input is null
      * @throws IOException if an I/O error occurs
+     * @deprecated 2.5 use {@link #toString(InputStream, Charset)} instead
      */
+    @Deprecated
     public static String toString(final InputStream input) throws IOException {
         return toString(input, Charset.defaultCharset());
     }
@@ -831,7 +837,9 @@ public class IOUtils {
      * @return The contents of the URL as a String.
      * @throws IOException if an I/O exception occurs.
      * @since 2.1
+     * @deprecated 2.5 use {@link #toString(URI, Charset)} instead
      */
+    @Deprecated
     public static String toString(final URI uri) throws IOException {
         return toString(uri, Charset.defaultCharset());
     }
@@ -877,7 +885,9 @@ public class IOUtils {
      * @return The contents of the URL as a String.
      * @throws IOException if an I/O exception occurs.
      * @since 2.1
+     * @deprecated 2.5 use {@link #toString(URL, Charset)} instead
      */
+    @Deprecated
     public static String toString(final URL url) throws IOException {
         return toString(url, Charset.defaultCharset());
     }
@@ -928,7 +938,7 @@ public class IOUtils {
      * @return the requested String
      * @throws NullPointerException if the input is null
      * @throws IOException if an I/O error occurs (never occurs)
-     * @deprecated Use {@link String#String(byte[])}
+     * @deprecated 2.5 Use {@link String#String(byte[])} instead
      */
     @Deprecated
     public static String toString(final byte[] input) throws IOException {
@@ -967,7 +977,9 @@ public class IOUtils {
      * @throws NullPointerException if the input is null
      * @throws IOException if an I/O error occurs
      * @since 1.1
+     * @deprecated 2.5 use {@link #readLines(InputStream, Charset)} instead
      */
+    @Deprecated
     public static List<String> readLines(final InputStream input) throws IOException {
         return readLines(input, Charset.defaultCharset());
     }
@@ -1151,7 +1163,9 @@ public class IOUtils {
      * @param input the CharSequence to convert
      * @return an input stream
      * @since 2.0
+     * @deprecated 2.5 use {@link #toInputStream(CharSequence, Charset)} instead
      */
+    @Deprecated
     public static InputStream toInputStream(final CharSequence input) {
         return toInputStream(input, Charset.defaultCharset());
     }
@@ -1197,7 +1211,9 @@ public class IOUtils {
      * @param input the string to convert
      * @return an input stream
      * @since 1.1
+     * @deprecated 2.5 use {@link #toInputStream(String, Charset)} instead
      */
+    @Deprecated
     public static InputStream toInputStream(final String input) {
         return toInputStream(input, Charset.defaultCharset());
     }
@@ -1267,7 +1283,9 @@ public class IOUtils {
      * @throws NullPointerException if output is null
      * @throws IOException if an I/O error occurs
      * @since 1.1
+     * @deprecated 2.5 use {@link #write(byte[], Writer, Charset)} instead
      */
+    @Deprecated
     public static void write(final byte[] data, final Writer output) throws IOException {
         write(data, output, Charset.defaultCharset());
     }
@@ -1348,7 +1366,9 @@ public class IOUtils {
      * @throws NullPointerException if output is null
      * @throws IOException if an I/O error occurs
      * @since 1.1
+     * @deprecated 2.5 use {@link #write(char[], OutputStream, Charset)} instead
      */
+    @Deprecated
     public static void write(final char[] data, final OutputStream output)
             throws IOException {
         write(data, output, Charset.defaultCharset());
@@ -1430,7 +1450,9 @@ public class IOUtils {
      * @throws NullPointerException if output is null
      * @throws IOException if an I/O error occurs
      * @since 2.0
+     * @deprecated 2.5 use {@link #write(CharSequence, OutputStream, Charset)} instead
      */
+    @Deprecated
     public static void write(final CharSequence data, final OutputStream output)
             throws IOException {
         write(data, output, Charset.defaultCharset());
@@ -1507,7 +1529,9 @@ public class IOUtils {
      * @throws NullPointerException if output is null
      * @throws IOException if an I/O error occurs
      * @since 1.1
+     * @deprecated 2.5 use {@link #write(String, OutputStream, Charset)} instead
      */
+    @Deprecated
     public static void write(final String data, final OutputStream output)
             throws IOException {
         write(data, output, Charset.defaultCharset());
@@ -1636,7 +1660,9 @@ public class IOUtils {
      * @throws NullPointerException if the output is null
      * @throws IOException if an I/O error occurs
      * @since 1.1
+     * @deprecated 2.5 use {@link #writeLines(Collection, String, OutputStream, Charset)} instead
      */
+    @Deprecated
     public static void writeLines(final Collection<?> lines, final String lineEnding,
             final OutputStream output) throws IOException {
         writeLines(lines, lineEnding, output, Charset.defaultCharset());
@@ -1918,7 +1944,9 @@ public class IOUtils {
      * @throws NullPointerException if the input or output is null
      * @throws IOException if an I/O error occurs
      * @since 1.1
+     * @deprecated 2.5 use {@link #copy(InputStream, Writer, Charset)} instead
      */
+    @Deprecated
     public static void copy(final InputStream input, final Writer output)
             throws IOException {
         copy(input, output, Charset.defaultCharset());
@@ -2129,7 +2157,9 @@ public class IOUtils {
      * @throws NullPointerException if the input or output is null
      * @throws IOException if an I/O error occurs
      * @since 1.1
+     * @deprecated 2.5 use {@link #copy(Reader, OutputStream, Charset)} instead
      */
+    @Deprecated
     public static void copy(final Reader input, final OutputStream output)
             throws IOException {
         copy(input, output, Charset.defaultCharset());

Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReaderInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReaderInputStream.java?rev=1468992&r1=1468991&r2=1468992&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReaderInputStream.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReaderInputStream.java Wed Apr 17 16:38:56 2013
@@ -177,7 +177,9 @@ public class ReaderInputStream extends I
      * with a default input buffer size of 1024 characters.
      * 
      * @param reader the target {@link Reader}
+     * @deprecated 2.5 use {@link #ReaderInputStream(Reader, Charset)} instead
      */
+    @Deprecated
     public ReaderInputStream(final Reader reader) {
         this(reader, Charset.defaultCharset());
     }

Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java?rev=1468992&r1=1468991&r2=1468992&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java Wed Apr 17 16:38:56 2013
@@ -58,9 +58,25 @@ public class ReversedLinesFileReader imp
      * @param file
      *            the file to be read
      * @throws IOException  if an I/O error occurs
+     * @deprecated 2.5 use {@link #ReversedLinesFileReader(File, Charset)} instead
      */
+    @Deprecated
     public ReversedLinesFileReader(final File file) throws IOException {
-        this(file, 4096, Charset.defaultCharset().toString());
+        this(file, 4096, Charset.defaultCharset());
+    }
+
+    /**
+     * Creates a ReversedLinesFileReader with default block size of 4KB and the
+     * specified encoding.
+     *
+     * @param file
+     *            the file to be read
+     * @param charset the encoding to use
+     * @throws IOException  if an I/O error occurs
+     * @since 2.5
+     */
+    public ReversedLinesFileReader(final File file, final Charset charset) throws IOException {
+        this(file, 4096, charset);
     }
 
     /**

Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java?rev=1468992&r1=1468991&r2=1468992&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java Wed Apr 17 16:38:56 2013
@@ -353,8 +353,10 @@ public class ByteArrayOutputStream exten
      * using the platform default charset.
      * @return the contents of the byte array as a String
      * @see java.io.ByteArrayOutputStream#toString()
+     * @deprecated 2.5 use {@link #toString(String)} instead
      */
     @Override
+    @Deprecated
     public String toString() {
         // make explicit the use of the default charset
         return new String(toByteArray(), Charset.defaultCharset());

Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/LockableFileWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/LockableFileWriter.java?rev=1468992&r1=1468991&r2=1468992&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/LockableFileWriter.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/LockableFileWriter.java Wed Apr 17 16:38:56 2013
@@ -131,7 +131,9 @@ public class LockableFileWriter extends 
      * @param lockDir  the directory in which the lock file should be held
      * @throws NullPointerException if the file is null
      * @throws IOException in case of an I/O error
+     * @deprecated 2.5 use {@link #LockableFileWriter(File, Charset, boolean, String)} instead
      */
+    @Deprecated
     public LockableFileWriter(final File file, final boolean append, final String lockDir) throws IOException {
         this(file, Charset.defaultCharset(), append, lockDir);
     }

Modified: commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/WriterOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/WriterOutputStream.java?rev=1468992&r1=1468991&r2=1468992&view=diff
==============================================================================
--- commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/WriterOutputStream.java (original)
+++ commons/proper/io/trunk/src/main/java/org/apache/commons/io/output/WriterOutputStream.java Wed Apr 17 16:38:56 2013
@@ -192,7 +192,9 @@ public class WriterOutputStream extends 
      * be flushed when it overflows or when {@link #flush()} or {@link #close()} is called.
      * 
      * @param writer the target {@link Writer}
+     * @deprecated 2.5 use {@link #WriterOutputStream(Writer, Charset)} instead
      */
+    @Deprecated
     public WriterOutputStream(final Writer writer) {
         this(writer, Charset.defaultCharset(), DEFAULT_BUFFER_SIZE, false);
     }