commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Colebourne <scolebou...@btopenworld.com>
Subject Re: svn commit: r491112 - /jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java
Date Fri, 29 Dec 2006 22:25:08 GMT
You need to add these to RELEASE-NOTES ;-)

Stephen


bayard@apache.org wrote:
> Author: bayard
> Date: Fri Dec 29 13:44:17 2006
> New Revision: 491112
> 
> URL: http://svn.apache.org/viewvc?view=rev&rev=491112
> Log:
> Added default encoding variants for 6 methods in FileUtils. See: #IO-108
> 
> Modified:
>     jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java
> 
> Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java
> URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java?view=diff&rev=491112&r1=491111&r2=491112
> ==============================================================================
> --- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java (original)
> +++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java Fri
Dec 29 13:44:17 2006
> @@ -946,10 +946,6 @@
>      /**
>       * Reads the contents of a file into a String.
>       * The file is always closed.
> -     * <p>
> -     * There is no readFileToString method without encoding parameter because
> -     * the default encoding can differ between platforms and will have
> -     * inconsistent results.
>       *
>       * @param file  the file to read, not null
>       * @param encoding  the encoding to use, null means platform default
> @@ -967,6 +963,20 @@
>          }
>      }
>  
> +
> +    /**
> +     * Reads the contents of a file into a String using the default encoding for the
VM. 
> +     * The file is always closed.
> +     *
> +     * @param file  the file to read, not null
> +     * @return the file contents, never null
> +     * @throws IOException in case of an I/O error
> +     * @since Commons IO 1.3
> +     */
> +    public String readFileToString(File f) throws IOException {
> +        return readFileToString(f, null);
> +    }
> +
>      /**
>       * Reads the contents of a file into a byte array.
>       * The file is always closed.
> @@ -989,10 +999,6 @@
>      /**
>       * Reads the contents of a file line by line to a List of Strings.
>       * The file is always closed.
> -     * <p>
> -     * There is no readLines method without encoding parameter because
> -     * the default encoding can differ between platforms and will have
> -     * inconsistent results.
>       *
>       * @param file  the file to read, not null
>       * @param encoding  the encoding to use, null means platform default
> @@ -1012,6 +1018,19 @@
>      }
>  
>      /**
> +     * Reads the contents of a file line by line to a List of Strings using the default
encoding for the VM.
> +     * The file is always closed.
> +     *
> +     * @param file  the file to read, not null
> +     * @return the list of Strings representing each line in the file, never null
> +     * @throws IOException in case of an I/O error
> +     * @since Commons IO 1.3
> +     */
> +    public static List readLines(File file) throws IOException {
> +        return readLines(file, null);
> +    }
> +
> +    /**
>       * Return an Iterator for the lines in a <code>File</code>.
>       * <p>
>       * This method opens an <code>InputStream</code> for the file.
> @@ -1035,10 +1054,6 @@
>       * <p>
>       * If an exception occurs during the creation of the iterator, the
>       * underlying stream is closed.
> -     * <p>
> -     * There is no lineIterator method without encoding parameter because
> -     * the default encoding can differ between platforms and will have
> -     * inconsistent results.
>       *
>       * @param file  the file to read, not null
>       * @param encoding  the encoding to use, null means platform default
> @@ -1060,14 +1075,20 @@
>          }
>      }
>  
> +    /**
> +     * Return an Iterator for the lines in a <code>File</code> using the
default encoding for the VM.
> +     *
> +     * @since Commons IO 1.3
> +     * @see lineIterator(File, String)
> +     */
> +    public static LineIterator lineIterator(File file) throws IOException {
> +        return lineIterator(file, null);
> +    }
> +
>      //-----------------------------------------------------------------------
>      /**
>       * Writes a String to a file creating the file if it does not exist.
> -     * <p>
> -     * There is no writeStringToFile method without encoding parameter because
> -     * the default encoding can differ between platforms and will have
> -     * inconsistent results.
> -     * <p>
> +     *
>       * NOTE: As from v1.3, the parent directories of the file will be created
>       * if they do not exist.
>       *
> @@ -1088,6 +1109,17 @@
>      }
>  
>      /**
> +     * Writes a String to a file creating the file if it does not exist using the default
encoding for the VM.
> +     * 
> +     * @param file  the file to write
> +     * @param data  the content to write to the file
> +     * @throws IOException in case of an I/O error
> +     */
> +    public static void writeStringToFile(File file, String data) throws IOException
{
> +        writeStringToFile(file, data, null);
> +    }
> +
> +    /**
>       * Writes a byte array to a file creating the file if it does not exist.
>       * <p>
>       * NOTE: As from v1.3, the parent directories of the file will be created
> @@ -1113,10 +1145,6 @@
>       * the specified <code>File</code> line by line.
>       * The specified character encoding and the default line ending will be used.
>       * <p>
> -     * There is no writeLines method without encoding parameter because
> -     * the default encoding can differ between platforms and will have
> -     * inconsistent results.
> -     * <p>
>       * NOTE: As from v1.3, the parent directories of the file will be created
>       * if they do not exist.
>       *
> @@ -1134,12 +1162,22 @@
>      /**
>       * Writes the <code>toString()</code> value of each item in a collection
to
>       * the specified <code>File</code> line by line.
> +     * The default VM encoding and the default line ending will be used.
> +     *
> +     * @param file  the file to write to
> +     * @param lines  the lines to write, null entries produce blank lines
> +     * @throws IOException in case of an I/O error
> +     * @since Commons IO 1.3
> +     */
> +    public static void writeLines(File file, Collection lines) throws IOException {
> +        writeLines(file, null, lines, null);
> +    }
> +
> +    /**
> +     * Writes the <code>toString()</code> value of each item in a collection
to
> +     * the specified <code>File</code> line by line.
>       * The specified character encoding and the line ending will be used.
>       * <p>
> -     * There is no writeLines method without encoding parameter because
> -     * the default encoding can differ between platforms and will have
> -     * inconsistent results.
> -     * <p>
>       * NOTE: As from v1.3, the parent directories of the file will be created
>       * if they do not exist.
>       *
> @@ -1159,6 +1197,21 @@
>          } finally {
>              IOUtils.closeQuietly(out);
>          }
> +    }
> +
> +    /**
> +     * Writes the <code>toString()</code> value of each item in a collection
to
> +     * the specified <code>File</code> line by line.
> +     * The default VM encoding and the specified line ending will be used.
> +     *
> +     * @param file  the file to write to
> +     * @param lines  the lines to write, null entries produce blank lines
> +     * @param lineEnding  the line separator to use, null is system default
> +     * @throws IOException in case of an I/O error
> +     * @since Commons IO 1.3
> +     */
> +    public static void writeLines(File file, Collection lines, String lineEnding) throws
IOException {
> +        writeLines(file, null, lines, lineEnding);
>      }
>  
>      //-----------------------------------------------------------------------
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message