commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r861378 [3/41] - in /websites/production/commons/content/proper/commons-io: ./ apidocs/ apidocs/org/apache/commons/io/ apidocs/src-html/org/apache/commons/io/ cobertura/ xref/org/apache/commons/io/
Date Wed, 08 May 2013 19:32:41 GMT
Modified: websites/production/commons/content/proper/commons-io/apidocs/src-html/org/apache/commons/io/FileUtils.html
==============================================================================
--- websites/production/commons/content/proper/commons-io/apidocs/src-html/org/apache/commons/io/FileUtils.html (original)
+++ websites/production/commons/content/proper/commons-io/apidocs/src-html/org/apache/commons/io/FileUtils.html Wed May  8 19:32:39 2013
@@ -79,7 +79,7 @@
 <span class="sourceLineNo">071</span> * &lt;p&gt;<a name="line.71"></a>
 <span class="sourceLineNo">072</span> * Origin of code: Excalibur, Alexandria, Commons-Utils<a name="line.72"></a>
 <span class="sourceLineNo">073</span> *<a name="line.73"></a>
-<span class="sourceLineNo">074</span> * @version $Id: FileUtils.java 1480300 2013-05-08 14:36:32Z ggregory $<a name="line.74"></a>
+<span class="sourceLineNo">074</span> * @version $Id: FileUtils.java 1480346 2013-05-08 16:45:03Z ggregory $<a name="line.74"></a>
 <span class="sourceLineNo">075</span> */<a name="line.75"></a>
 <span class="sourceLineNo">076</span>public class FileUtils {<a name="line.76"></a>
 <span class="sourceLineNo">077</span><a name="line.77"></a>
@@ -1515,1541 +1515,1538 @@
 <span class="sourceLineNo">1507</span>     * @since 2.0<a name="line.1507"></a>
 <span class="sourceLineNo">1508</span>     */<a name="line.1508"></a>
 <span class="sourceLineNo">1509</span>    public static void copyInputStreamToFile(final InputStream source, final File destination) throws IOException {<a name="line.1509"></a>
-<span class="sourceLineNo">1510</span>        copyInputStreamToFile(source, destination, true);<a name="line.1510"></a>
-<span class="sourceLineNo">1511</span>    }<a name="line.1511"></a>
-<span class="sourceLineNo">1512</span><a name="line.1512"></a>
-<span class="sourceLineNo">1513</span>    /**<a name="line.1513"></a>
-<span class="sourceLineNo">1514</span>     * Copies bytes from an {@link InputStream} &lt;code&gt;source&lt;/code&gt; to a file<a name="line.1514"></a>
-<span class="sourceLineNo">1515</span>     * &lt;code&gt;destination&lt;/code&gt;. The directories up to &lt;code&gt;destination&lt;/code&gt;<a name="line.1515"></a>
-<span class="sourceLineNo">1516</span>     * will be created if they don't already exist. &lt;code&gt;destination&lt;/code&gt;<a name="line.1516"></a>
-<span class="sourceLineNo">1517</span>     * will be overwritten if it already exists.<a name="line.1517"></a>
-<span class="sourceLineNo">1518</span>     *<a name="line.1518"></a>
-<span class="sourceLineNo">1519</span>     * @param source  the &lt;code&gt;InputStream&lt;/code&gt; to copy bytes from, must not be {@code null}<a name="line.1519"></a>
-<span class="sourceLineNo">1520</span>     * @param destination  the non-directory &lt;code&gt;File&lt;/code&gt; to write bytes to<a name="line.1520"></a>
-<span class="sourceLineNo">1521</span>     *  (possibly overwriting), must not be {@code null}<a name="line.1521"></a>
-<span class="sourceLineNo">1522</span>     * @param closeSource If true, closes the &lt;code&gt;source&lt;/code&gt;<a name="line.1522"></a>
-<span class="sourceLineNo">1523</span>     * @throws IOException if &lt;code&gt;destination&lt;/code&gt; is a directory<a name="line.1523"></a>
-<span class="sourceLineNo">1524</span>     * @throws IOException if &lt;code&gt;destination&lt;/code&gt; cannot be written<a name="line.1524"></a>
-<span class="sourceLineNo">1525</span>     * @throws IOException if &lt;code&gt;destination&lt;/code&gt; needs creating but can't be<a name="line.1525"></a>
-<span class="sourceLineNo">1526</span>     * @throws IOException if an IO error occurs during copying<a name="line.1526"></a>
-<span class="sourceLineNo">1527</span>     * @since 2.5<a name="line.1527"></a>
-<span class="sourceLineNo">1528</span>     */<a name="line.1528"></a>
-<span class="sourceLineNo">1529</span>    public static void copyInputStreamToFile(final InputStream source, final File destination, boolean closeSource) <a name="line.1529"></a>
-<span class="sourceLineNo">1530</span>            throws IOException {<a name="line.1530"></a>
-<span class="sourceLineNo">1531</span>        try {<a name="line.1531"></a>
-<span class="sourceLineNo">1532</span>            final FileOutputStream output = openOutputStream(destination);<a name="line.1532"></a>
-<span class="sourceLineNo">1533</span>            try {<a name="line.1533"></a>
-<span class="sourceLineNo">1534</span>                IOUtils.copy(source, output);<a name="line.1534"></a>
-<span class="sourceLineNo">1535</span>                output.close(); // don't swallow close Exception if copy completes normally<a name="line.1535"></a>
-<span class="sourceLineNo">1536</span>            } finally {<a name="line.1536"></a>
-<span class="sourceLineNo">1537</span>                IOUtils.closeQuietly(output);<a name="line.1537"></a>
-<span class="sourceLineNo">1538</span>            }<a name="line.1538"></a>
-<span class="sourceLineNo">1539</span>        } finally {<a name="line.1539"></a>
-<span class="sourceLineNo">1540</span>            if (closeSource) {<a name="line.1540"></a>
-<span class="sourceLineNo">1541</span>                IOUtils.closeQuietly(source);<a name="line.1541"></a>
-<span class="sourceLineNo">1542</span>            }<a name="line.1542"></a>
-<span class="sourceLineNo">1543</span>        }<a name="line.1543"></a>
-<span class="sourceLineNo">1544</span>    }<a name="line.1544"></a>
-<span class="sourceLineNo">1545</span><a name="line.1545"></a>
-<span class="sourceLineNo">1546</span>    //-----------------------------------------------------------------------<a name="line.1546"></a>
-<span class="sourceLineNo">1547</span>    /**<a name="line.1547"></a>
-<span class="sourceLineNo">1548</span>     * Deletes a directory recursively.<a name="line.1548"></a>
-<span class="sourceLineNo">1549</span>     *<a name="line.1549"></a>
-<span class="sourceLineNo">1550</span>     * @param directory  directory to delete<a name="line.1550"></a>
-<span class="sourceLineNo">1551</span>     * @throws IOException in case deletion is unsuccessful<a name="line.1551"></a>
-<span class="sourceLineNo">1552</span>     */<a name="line.1552"></a>
-<span class="sourceLineNo">1553</span>    public static void deleteDirectory(final File directory) throws IOException {<a name="line.1553"></a>
-<span class="sourceLineNo">1554</span>        if (!directory.exists()) {<a name="line.1554"></a>
-<span class="sourceLineNo">1555</span>            return;<a name="line.1555"></a>
-<span class="sourceLineNo">1556</span>        }<a name="line.1556"></a>
-<span class="sourceLineNo">1557</span><a name="line.1557"></a>
-<span class="sourceLineNo">1558</span>        if (!isSymlink(directory)) {<a name="line.1558"></a>
-<span class="sourceLineNo">1559</span>            cleanDirectory(directory);<a name="line.1559"></a>
-<span class="sourceLineNo">1560</span>        }<a name="line.1560"></a>
-<span class="sourceLineNo">1561</span><a name="line.1561"></a>
-<span class="sourceLineNo">1562</span>        if (!directory.delete()) {<a name="line.1562"></a>
-<span class="sourceLineNo">1563</span>            final String message =<a name="line.1563"></a>
-<span class="sourceLineNo">1564</span>                "Unable to delete directory " + directory + ".";<a name="line.1564"></a>
-<span class="sourceLineNo">1565</span>            throw new IOException(message);<a name="line.1565"></a>
-<span class="sourceLineNo">1566</span>        }<a name="line.1566"></a>
-<span class="sourceLineNo">1567</span>    }<a name="line.1567"></a>
-<span class="sourceLineNo">1568</span><a name="line.1568"></a>
-<span class="sourceLineNo">1569</span>    /**<a name="line.1569"></a>
-<span class="sourceLineNo">1570</span>     * Deletes a file, never throwing an exception. If file is a directory, delete it and all sub-directories.<a name="line.1570"></a>
-<span class="sourceLineNo">1571</span>     * &lt;p&gt;<a name="line.1571"></a>
-<span class="sourceLineNo">1572</span>     * The difference between File.delete() and this method are:<a name="line.1572"></a>
-<span class="sourceLineNo">1573</span>     * &lt;ul&gt;<a name="line.1573"></a>
-<span class="sourceLineNo">1574</span>     * &lt;li&gt;A directory to be deleted does not have to be empty.&lt;/li&gt;<a name="line.1574"></a>
-<span class="sourceLineNo">1575</span>     * &lt;li&gt;No exceptions are thrown when a file or directory cannot be deleted.&lt;/li&gt;<a name="line.1575"></a>
-<span class="sourceLineNo">1576</span>     * &lt;/ul&gt;<a name="line.1576"></a>
-<span class="sourceLineNo">1577</span>     *<a name="line.1577"></a>
-<span class="sourceLineNo">1578</span>     * @param file  file or directory to delete, can be {@code null}<a name="line.1578"></a>
-<span class="sourceLineNo">1579</span>     * @return {@code true} if the file or directory was deleted, otherwise<a name="line.1579"></a>
-<span class="sourceLineNo">1580</span>     * {@code false}<a name="line.1580"></a>
-<span class="sourceLineNo">1581</span>     *<a name="line.1581"></a>
-<span class="sourceLineNo">1582</span>     * @since 1.4<a name="line.1582"></a>
-<span class="sourceLineNo">1583</span>     */<a name="line.1583"></a>
-<span class="sourceLineNo">1584</span>    public static boolean deleteQuietly(final File file) {<a name="line.1584"></a>
-<span class="sourceLineNo">1585</span>        if (file == null) {<a name="line.1585"></a>
-<span class="sourceLineNo">1586</span>            return false;<a name="line.1586"></a>
-<span class="sourceLineNo">1587</span>        }<a name="line.1587"></a>
-<span class="sourceLineNo">1588</span>        try {<a name="line.1588"></a>
-<span class="sourceLineNo">1589</span>            if (file.isDirectory()) {<a name="line.1589"></a>
-<span class="sourceLineNo">1590</span>                cleanDirectory(file);<a name="line.1590"></a>
-<span class="sourceLineNo">1591</span>            }<a name="line.1591"></a>
-<span class="sourceLineNo">1592</span>        } catch (final Exception ignored) {<a name="line.1592"></a>
-<span class="sourceLineNo">1593</span>        }<a name="line.1593"></a>
-<span class="sourceLineNo">1594</span><a name="line.1594"></a>
-<span class="sourceLineNo">1595</span>        try {<a name="line.1595"></a>
-<span class="sourceLineNo">1596</span>            return file.delete();<a name="line.1596"></a>
-<span class="sourceLineNo">1597</span>        } catch (final Exception ignored) {<a name="line.1597"></a>
-<span class="sourceLineNo">1598</span>            return false;<a name="line.1598"></a>
-<span class="sourceLineNo">1599</span>        }<a name="line.1599"></a>
-<span class="sourceLineNo">1600</span>    }<a name="line.1600"></a>
-<span class="sourceLineNo">1601</span><a name="line.1601"></a>
-<span class="sourceLineNo">1602</span>    /**<a name="line.1602"></a>
-<span class="sourceLineNo">1603</span>     * Determines whether the {@code parent} directory contains the {@code child} element (a file or directory).<a name="line.1603"></a>
-<span class="sourceLineNo">1604</span>     * &lt;p&gt;<a name="line.1604"></a>
-<span class="sourceLineNo">1605</span>     * Files are normalized before comparison.<a name="line.1605"></a>
-<span class="sourceLineNo">1606</span>     * &lt;/p&gt;<a name="line.1606"></a>
-<span class="sourceLineNo">1607</span>     *<a name="line.1607"></a>
-<span class="sourceLineNo">1608</span>     * Edge cases:<a name="line.1608"></a>
-<span class="sourceLineNo">1609</span>     * &lt;ul&gt;<a name="line.1609"></a>
-<span class="sourceLineNo">1610</span>     * &lt;li&gt;A {@code directory} must not be null: if null, throw IllegalArgumentException&lt;/li&gt;<a name="line.1610"></a>
-<span class="sourceLineNo">1611</span>     * &lt;li&gt;A {@code directory} must be a directory: if not a directory, throw IllegalArgumentException&lt;/li&gt;<a name="line.1611"></a>
-<span class="sourceLineNo">1612</span>     * &lt;li&gt;A directory does not contain itself: return false&lt;/li&gt;<a name="line.1612"></a>
-<span class="sourceLineNo">1613</span>     * &lt;li&gt;A null child file is not contained in any parent: return false&lt;/li&gt;<a name="line.1613"></a>
-<span class="sourceLineNo">1614</span>     * &lt;/ul&gt;<a name="line.1614"></a>
-<span class="sourceLineNo">1615</span>     *<a name="line.1615"></a>
-<span class="sourceLineNo">1616</span>     * @param directory<a name="line.1616"></a>
-<span class="sourceLineNo">1617</span>     *            the file to consider as the parent.<a name="line.1617"></a>
-<span class="sourceLineNo">1618</span>     * @param child<a name="line.1618"></a>
-<span class="sourceLineNo">1619</span>     *            the file to consider as the child.<a name="line.1619"></a>
-<span class="sourceLineNo">1620</span>     * @return true is the candidate leaf is under by the specified composite. False otherwise.<a name="line.1620"></a>
-<span class="sourceLineNo">1621</span>     * @throws IOException<a name="line.1621"></a>
-<span class="sourceLineNo">1622</span>     *             if an IO error occurs while checking the files.<a name="line.1622"></a>
-<span class="sourceLineNo">1623</span>     * @since 2.2<a name="line.1623"></a>
-<span class="sourceLineNo">1624</span>     * @see FilenameUtils#directoryContains(String, String)<a name="line.1624"></a>
-<span class="sourceLineNo">1625</span>     */<a name="line.1625"></a>
-<span class="sourceLineNo">1626</span>    public static boolean directoryContains(final File directory, final File child) throws IOException {<a name="line.1626"></a>
-<span class="sourceLineNo">1627</span><a name="line.1627"></a>
-<span class="sourceLineNo">1628</span>        // Fail fast against NullPointerException<a name="line.1628"></a>
-<span class="sourceLineNo">1629</span>        if (directory == null) {<a name="line.1629"></a>
-<span class="sourceLineNo">1630</span>            throw new IllegalArgumentException("Directory must not be null");<a name="line.1630"></a>
-<span class="sourceLineNo">1631</span>        }<a name="line.1631"></a>
-<span class="sourceLineNo">1632</span><a name="line.1632"></a>
-<span class="sourceLineNo">1633</span>        if (!directory.isDirectory()) {<a name="line.1633"></a>
-<span class="sourceLineNo">1634</span>            throw new IllegalArgumentException("Not a directory: " + directory);<a name="line.1634"></a>
-<span class="sourceLineNo">1635</span>        }<a name="line.1635"></a>
-<span class="sourceLineNo">1636</span><a name="line.1636"></a>
-<span class="sourceLineNo">1637</span>        if (child == null) {<a name="line.1637"></a>
-<span class="sourceLineNo">1638</span>            return false;<a name="line.1638"></a>
-<span class="sourceLineNo">1639</span>        }<a name="line.1639"></a>
-<span class="sourceLineNo">1640</span><a name="line.1640"></a>
-<span class="sourceLineNo">1641</span>        if (!directory.exists() || !child.exists()) {<a name="line.1641"></a>
-<span class="sourceLineNo">1642</span>            return false;<a name="line.1642"></a>
-<span class="sourceLineNo">1643</span>        }<a name="line.1643"></a>
-<span class="sourceLineNo">1644</span><a name="line.1644"></a>
-<span class="sourceLineNo">1645</span>        // Canonicalize paths (normalizes relative paths)<a name="line.1645"></a>
-<span class="sourceLineNo">1646</span>        final String canonicalParent = directory.getCanonicalPath();<a name="line.1646"></a>
-<span class="sourceLineNo">1647</span>        final String canonicalChild = child.getCanonicalPath();<a name="line.1647"></a>
+<span class="sourceLineNo">1510</span>        try {<a name="line.1510"></a>
+<span class="sourceLineNo">1511</span>            copyToFile(source, destination);<a name="line.1511"></a>
+<span class="sourceLineNo">1512</span>        } finally {<a name="line.1512"></a>
+<span class="sourceLineNo">1513</span>            IOUtils.closeQuietly(source);<a name="line.1513"></a>
+<span class="sourceLineNo">1514</span>        }<a name="line.1514"></a>
+<span class="sourceLineNo">1515</span>    }<a name="line.1515"></a>
+<span class="sourceLineNo">1516</span><a name="line.1516"></a>
+<span class="sourceLineNo">1517</span>    /**<a name="line.1517"></a>
+<span class="sourceLineNo">1518</span>     * Copies bytes from an {@link InputStream} &lt;code&gt;source&lt;/code&gt; to a file<a name="line.1518"></a>
+<span class="sourceLineNo">1519</span>     * &lt;code&gt;destination&lt;/code&gt;. The directories up to &lt;code&gt;destination&lt;/code&gt;<a name="line.1519"></a>
+<span class="sourceLineNo">1520</span>     * will be created if they don't already exist. &lt;code&gt;destination&lt;/code&gt;<a name="line.1520"></a>
+<span class="sourceLineNo">1521</span>     * will be overwritten if it already exists.<a name="line.1521"></a>
+<span class="sourceLineNo">1522</span>     * The {@code source} stream is closed.<a name="line.1522"></a>
+<span class="sourceLineNo">1523</span>     *<a name="line.1523"></a>
+<span class="sourceLineNo">1524</span>     * @param source  the &lt;code&gt;InputStream&lt;/code&gt; to copy bytes from, must not be {@code null}<a name="line.1524"></a>
+<span class="sourceLineNo">1525</span>     * @param destination  the non-directory &lt;code&gt;File&lt;/code&gt; to write bytes to<a name="line.1525"></a>
+<span class="sourceLineNo">1526</span>     *  (possibly overwriting), must not be {@code null}<a name="line.1526"></a>
+<span class="sourceLineNo">1527</span>     * @throws IOException if &lt;code&gt;destination&lt;/code&gt; is a directory<a name="line.1527"></a>
+<span class="sourceLineNo">1528</span>     * @throws IOException if &lt;code&gt;destination&lt;/code&gt; cannot be written<a name="line.1528"></a>
+<span class="sourceLineNo">1529</span>     * @throws IOException if &lt;code&gt;destination&lt;/code&gt; needs creating but can't be<a name="line.1529"></a>
+<span class="sourceLineNo">1530</span>     * @throws IOException if an IO error occurs during copying<a name="line.1530"></a>
+<span class="sourceLineNo">1531</span>     * @since 2.5<a name="line.1531"></a>
+<span class="sourceLineNo">1532</span>     */<a name="line.1532"></a>
+<span class="sourceLineNo">1533</span>    public static void copyToFile(final InputStream source, final File destination) throws IOException {<a name="line.1533"></a>
+<span class="sourceLineNo">1534</span>        final FileOutputStream output = openOutputStream(destination);<a name="line.1534"></a>
+<span class="sourceLineNo">1535</span>        try {<a name="line.1535"></a>
+<span class="sourceLineNo">1536</span>            IOUtils.copy(source, output);<a name="line.1536"></a>
+<span class="sourceLineNo">1537</span>            output.close(); // don't swallow close Exception if copy completes normally<a name="line.1537"></a>
+<span class="sourceLineNo">1538</span>        } finally {<a name="line.1538"></a>
+<span class="sourceLineNo">1539</span>            IOUtils.closeQuietly(output);<a name="line.1539"></a>
+<span class="sourceLineNo">1540</span>        }<a name="line.1540"></a>
+<span class="sourceLineNo">1541</span>    }<a name="line.1541"></a>
+<span class="sourceLineNo">1542</span><a name="line.1542"></a>
+<span class="sourceLineNo">1543</span>    //-----------------------------------------------------------------------<a name="line.1543"></a>
+<span class="sourceLineNo">1544</span>    /**<a name="line.1544"></a>
+<span class="sourceLineNo">1545</span>     * Deletes a directory recursively.<a name="line.1545"></a>
+<span class="sourceLineNo">1546</span>     *<a name="line.1546"></a>
+<span class="sourceLineNo">1547</span>     * @param directory  directory to delete<a name="line.1547"></a>
+<span class="sourceLineNo">1548</span>     * @throws IOException in case deletion is unsuccessful<a name="line.1548"></a>
+<span class="sourceLineNo">1549</span>     */<a name="line.1549"></a>
+<span class="sourceLineNo">1550</span>    public static void deleteDirectory(final File directory) throws IOException {<a name="line.1550"></a>
+<span class="sourceLineNo">1551</span>        if (!directory.exists()) {<a name="line.1551"></a>
+<span class="sourceLineNo">1552</span>            return;<a name="line.1552"></a>
+<span class="sourceLineNo">1553</span>        }<a name="line.1553"></a>
+<span class="sourceLineNo">1554</span><a name="line.1554"></a>
+<span class="sourceLineNo">1555</span>        if (!isSymlink(directory)) {<a name="line.1555"></a>
+<span class="sourceLineNo">1556</span>            cleanDirectory(directory);<a name="line.1556"></a>
+<span class="sourceLineNo">1557</span>        }<a name="line.1557"></a>
+<span class="sourceLineNo">1558</span><a name="line.1558"></a>
+<span class="sourceLineNo">1559</span>        if (!directory.delete()) {<a name="line.1559"></a>
+<span class="sourceLineNo">1560</span>            final String message =<a name="line.1560"></a>
+<span class="sourceLineNo">1561</span>                "Unable to delete directory " + directory + ".";<a name="line.1561"></a>
+<span class="sourceLineNo">1562</span>            throw new IOException(message);<a name="line.1562"></a>
+<span class="sourceLineNo">1563</span>        }<a name="line.1563"></a>
+<span class="sourceLineNo">1564</span>    }<a name="line.1564"></a>
+<span class="sourceLineNo">1565</span><a name="line.1565"></a>
+<span class="sourceLineNo">1566</span>    /**<a name="line.1566"></a>
+<span class="sourceLineNo">1567</span>     * Deletes a file, never throwing an exception. If file is a directory, delete it and all sub-directories.<a name="line.1567"></a>
+<span class="sourceLineNo">1568</span>     * &lt;p&gt;<a name="line.1568"></a>
+<span class="sourceLineNo">1569</span>     * The difference between File.delete() and this method are:<a name="line.1569"></a>
+<span class="sourceLineNo">1570</span>     * &lt;ul&gt;<a name="line.1570"></a>
+<span class="sourceLineNo">1571</span>     * &lt;li&gt;A directory to be deleted does not have to be empty.&lt;/li&gt;<a name="line.1571"></a>
+<span class="sourceLineNo">1572</span>     * &lt;li&gt;No exceptions are thrown when a file or directory cannot be deleted.&lt;/li&gt;<a name="line.1572"></a>
+<span class="sourceLineNo">1573</span>     * &lt;/ul&gt;<a name="line.1573"></a>
+<span class="sourceLineNo">1574</span>     *<a name="line.1574"></a>
+<span class="sourceLineNo">1575</span>     * @param file  file or directory to delete, can be {@code null}<a name="line.1575"></a>
+<span class="sourceLineNo">1576</span>     * @return {@code true} if the file or directory was deleted, otherwise<a name="line.1576"></a>
+<span class="sourceLineNo">1577</span>     * {@code false}<a name="line.1577"></a>
+<span class="sourceLineNo">1578</span>     *<a name="line.1578"></a>
+<span class="sourceLineNo">1579</span>     * @since 1.4<a name="line.1579"></a>
+<span class="sourceLineNo">1580</span>     */<a name="line.1580"></a>
+<span class="sourceLineNo">1581</span>    public static boolean deleteQuietly(final File file) {<a name="line.1581"></a>
+<span class="sourceLineNo">1582</span>        if (file == null) {<a name="line.1582"></a>
+<span class="sourceLineNo">1583</span>            return false;<a name="line.1583"></a>
+<span class="sourceLineNo">1584</span>        }<a name="line.1584"></a>
+<span class="sourceLineNo">1585</span>        try {<a name="line.1585"></a>
+<span class="sourceLineNo">1586</span>            if (file.isDirectory()) {<a name="line.1586"></a>
+<span class="sourceLineNo">1587</span>                cleanDirectory(file);<a name="line.1587"></a>
+<span class="sourceLineNo">1588</span>            }<a name="line.1588"></a>
+<span class="sourceLineNo">1589</span>        } catch (final Exception ignored) {<a name="line.1589"></a>
+<span class="sourceLineNo">1590</span>        }<a name="line.1590"></a>
+<span class="sourceLineNo">1591</span><a name="line.1591"></a>
+<span class="sourceLineNo">1592</span>        try {<a name="line.1592"></a>
+<span class="sourceLineNo">1593</span>            return file.delete();<a name="line.1593"></a>
+<span class="sourceLineNo">1594</span>        } catch (final Exception ignored) {<a name="line.1594"></a>
+<span class="sourceLineNo">1595</span>            return false;<a name="line.1595"></a>
+<span class="sourceLineNo">1596</span>        }<a name="line.1596"></a>
+<span class="sourceLineNo">1597</span>    }<a name="line.1597"></a>
+<span class="sourceLineNo">1598</span><a name="line.1598"></a>
+<span class="sourceLineNo">1599</span>    /**<a name="line.1599"></a>
+<span class="sourceLineNo">1600</span>     * Determines whether the {@code parent} directory contains the {@code child} element (a file or directory).<a name="line.1600"></a>
+<span class="sourceLineNo">1601</span>     * &lt;p&gt;<a name="line.1601"></a>
+<span class="sourceLineNo">1602</span>     * Files are normalized before comparison.<a name="line.1602"></a>
+<span class="sourceLineNo">1603</span>     * &lt;/p&gt;<a name="line.1603"></a>
+<span class="sourceLineNo">1604</span>     *<a name="line.1604"></a>
+<span class="sourceLineNo">1605</span>     * Edge cases:<a name="line.1605"></a>
+<span class="sourceLineNo">1606</span>     * &lt;ul&gt;<a name="line.1606"></a>
+<span class="sourceLineNo">1607</span>     * &lt;li&gt;A {@code directory} must not be null: if null, throw IllegalArgumentException&lt;/li&gt;<a name="line.1607"></a>
+<span class="sourceLineNo">1608</span>     * &lt;li&gt;A {@code directory} must be a directory: if not a directory, throw IllegalArgumentException&lt;/li&gt;<a name="line.1608"></a>
+<span class="sourceLineNo">1609</span>     * &lt;li&gt;A directory does not contain itself: return false&lt;/li&gt;<a name="line.1609"></a>
+<span class="sourceLineNo">1610</span>     * &lt;li&gt;A null child file is not contained in any parent: return false&lt;/li&gt;<a name="line.1610"></a>
+<span class="sourceLineNo">1611</span>     * &lt;/ul&gt;<a name="line.1611"></a>
+<span class="sourceLineNo">1612</span>     *<a name="line.1612"></a>
+<span class="sourceLineNo">1613</span>     * @param directory<a name="line.1613"></a>
+<span class="sourceLineNo">1614</span>     *            the file to consider as the parent.<a name="line.1614"></a>
+<span class="sourceLineNo">1615</span>     * @param child<a name="line.1615"></a>
+<span class="sourceLineNo">1616</span>     *            the file to consider as the child.<a name="line.1616"></a>
+<span class="sourceLineNo">1617</span>     * @return true is the candidate leaf is under by the specified composite. False otherwise.<a name="line.1617"></a>
+<span class="sourceLineNo">1618</span>     * @throws IOException<a name="line.1618"></a>
+<span class="sourceLineNo">1619</span>     *             if an IO error occurs while checking the files.<a name="line.1619"></a>
+<span class="sourceLineNo">1620</span>     * @since 2.2<a name="line.1620"></a>
+<span class="sourceLineNo">1621</span>     * @see FilenameUtils#directoryContains(String, String)<a name="line.1621"></a>
+<span class="sourceLineNo">1622</span>     */<a name="line.1622"></a>
+<span class="sourceLineNo">1623</span>    public static boolean directoryContains(final File directory, final File child) throws IOException {<a name="line.1623"></a>
+<span class="sourceLineNo">1624</span><a name="line.1624"></a>
+<span class="sourceLineNo">1625</span>        // Fail fast against NullPointerException<a name="line.1625"></a>
+<span class="sourceLineNo">1626</span>        if (directory == null) {<a name="line.1626"></a>
+<span class="sourceLineNo">1627</span>            throw new IllegalArgumentException("Directory must not be null");<a name="line.1627"></a>
+<span class="sourceLineNo">1628</span>        }<a name="line.1628"></a>
+<span class="sourceLineNo">1629</span><a name="line.1629"></a>
+<span class="sourceLineNo">1630</span>        if (!directory.isDirectory()) {<a name="line.1630"></a>
+<span class="sourceLineNo">1631</span>            throw new IllegalArgumentException("Not a directory: " + directory);<a name="line.1631"></a>
+<span class="sourceLineNo">1632</span>        }<a name="line.1632"></a>
+<span class="sourceLineNo">1633</span><a name="line.1633"></a>
+<span class="sourceLineNo">1634</span>        if (child == null) {<a name="line.1634"></a>
+<span class="sourceLineNo">1635</span>            return false;<a name="line.1635"></a>
+<span class="sourceLineNo">1636</span>        }<a name="line.1636"></a>
+<span class="sourceLineNo">1637</span><a name="line.1637"></a>
+<span class="sourceLineNo">1638</span>        if (!directory.exists() || !child.exists()) {<a name="line.1638"></a>
+<span class="sourceLineNo">1639</span>            return false;<a name="line.1639"></a>
+<span class="sourceLineNo">1640</span>        }<a name="line.1640"></a>
+<span class="sourceLineNo">1641</span><a name="line.1641"></a>
+<span class="sourceLineNo">1642</span>        // Canonicalize paths (normalizes relative paths)<a name="line.1642"></a>
+<span class="sourceLineNo">1643</span>        final String canonicalParent = directory.getCanonicalPath();<a name="line.1643"></a>
+<span class="sourceLineNo">1644</span>        final String canonicalChild = child.getCanonicalPath();<a name="line.1644"></a>
+<span class="sourceLineNo">1645</span><a name="line.1645"></a>
+<span class="sourceLineNo">1646</span>        return FilenameUtils.directoryContains(canonicalParent, canonicalChild);<a name="line.1646"></a>
+<span class="sourceLineNo">1647</span>    }<a name="line.1647"></a>
 <span class="sourceLineNo">1648</span><a name="line.1648"></a>
-<span class="sourceLineNo">1649</span>        return FilenameUtils.directoryContains(canonicalParent, canonicalChild);<a name="line.1649"></a>
-<span class="sourceLineNo">1650</span>    }<a name="line.1650"></a>
-<span class="sourceLineNo">1651</span><a name="line.1651"></a>
-<span class="sourceLineNo">1652</span>    /**<a name="line.1652"></a>
-<span class="sourceLineNo">1653</span>     * Cleans a directory without deleting it.<a name="line.1653"></a>
-<span class="sourceLineNo">1654</span>     *<a name="line.1654"></a>
-<span class="sourceLineNo">1655</span>     * @param directory directory to clean<a name="line.1655"></a>
-<span class="sourceLineNo">1656</span>     * @throws IOException in case cleaning is unsuccessful<a name="line.1656"></a>
-<span class="sourceLineNo">1657</span>     */<a name="line.1657"></a>
-<span class="sourceLineNo">1658</span>    public static void cleanDirectory(final File directory) throws IOException {<a name="line.1658"></a>
-<span class="sourceLineNo">1659</span>        if (!directory.exists()) {<a name="line.1659"></a>
-<span class="sourceLineNo">1660</span>            final String message = directory + " does not exist";<a name="line.1660"></a>
-<span class="sourceLineNo">1661</span>            throw new IllegalArgumentException(message);<a name="line.1661"></a>
-<span class="sourceLineNo">1662</span>        }<a name="line.1662"></a>
-<span class="sourceLineNo">1663</span><a name="line.1663"></a>
-<span class="sourceLineNo">1664</span>        if (!directory.isDirectory()) {<a name="line.1664"></a>
-<span class="sourceLineNo">1665</span>            final String message = directory + " is not a directory";<a name="line.1665"></a>
-<span class="sourceLineNo">1666</span>            throw new IllegalArgumentException(message);<a name="line.1666"></a>
-<span class="sourceLineNo">1667</span>        }<a name="line.1667"></a>
-<span class="sourceLineNo">1668</span><a name="line.1668"></a>
-<span class="sourceLineNo">1669</span>        final File[] files = directory.listFiles();<a name="line.1669"></a>
-<span class="sourceLineNo">1670</span>        if (files == null) {  // null if security restricted<a name="line.1670"></a>
-<span class="sourceLineNo">1671</span>            throw new IOException("Failed to list contents of " + directory);<a name="line.1671"></a>
-<span class="sourceLineNo">1672</span>        }<a name="line.1672"></a>
-<span class="sourceLineNo">1673</span><a name="line.1673"></a>
-<span class="sourceLineNo">1674</span>        IOException exception = null;<a name="line.1674"></a>
-<span class="sourceLineNo">1675</span>        for (final File file : files) {<a name="line.1675"></a>
-<span class="sourceLineNo">1676</span>            try {<a name="line.1676"></a>
-<span class="sourceLineNo">1677</span>                forceDelete(file);<a name="line.1677"></a>
-<span class="sourceLineNo">1678</span>            } catch (final IOException ioe) {<a name="line.1678"></a>
-<span class="sourceLineNo">1679</span>                exception = ioe;<a name="line.1679"></a>
-<span class="sourceLineNo">1680</span>            }<a name="line.1680"></a>
-<span class="sourceLineNo">1681</span>        }<a name="line.1681"></a>
-<span class="sourceLineNo">1682</span><a name="line.1682"></a>
-<span class="sourceLineNo">1683</span>        if (null != exception) {<a name="line.1683"></a>
-<span class="sourceLineNo">1684</span>            throw exception;<a name="line.1684"></a>
-<span class="sourceLineNo">1685</span>        }<a name="line.1685"></a>
-<span class="sourceLineNo">1686</span>    }<a name="line.1686"></a>
-<span class="sourceLineNo">1687</span><a name="line.1687"></a>
-<span class="sourceLineNo">1688</span>    //-----------------------------------------------------------------------<a name="line.1688"></a>
-<span class="sourceLineNo">1689</span>    /**<a name="line.1689"></a>
-<span class="sourceLineNo">1690</span>     * Waits for NFS to propagate a file creation, imposing a timeout.<a name="line.1690"></a>
-<span class="sourceLineNo">1691</span>     * &lt;p&gt;<a name="line.1691"></a>
-<span class="sourceLineNo">1692</span>     * This method repeatedly tests {@link File#exists()} until it returns<a name="line.1692"></a>
-<span class="sourceLineNo">1693</span>     * true up to the maximum time specified in seconds.<a name="line.1693"></a>
-<span class="sourceLineNo">1694</span>     *<a name="line.1694"></a>
-<span class="sourceLineNo">1695</span>     * @param file  the file to check, must not be {@code null}<a name="line.1695"></a>
-<span class="sourceLineNo">1696</span>     * @param seconds  the maximum time in seconds to wait<a name="line.1696"></a>
-<span class="sourceLineNo">1697</span>     * @return true if file exists<a name="line.1697"></a>
-<span class="sourceLineNo">1698</span>     * @throws NullPointerException if the file is {@code null}<a name="line.1698"></a>
-<span class="sourceLineNo">1699</span>     */<a name="line.1699"></a>
-<span class="sourceLineNo">1700</span>    public static boolean waitFor(final File file, final int seconds) {<a name="line.1700"></a>
-<span class="sourceLineNo">1701</span>        int timeout = 0;<a name="line.1701"></a>
-<span class="sourceLineNo">1702</span>        int tick = 0;<a name="line.1702"></a>
-<span class="sourceLineNo">1703</span>        while (!file.exists()) {<a name="line.1703"></a>
-<span class="sourceLineNo">1704</span>            if (tick++ &gt;= 10) {<a name="line.1704"></a>
-<span class="sourceLineNo">1705</span>                tick = 0;<a name="line.1705"></a>
-<span class="sourceLineNo">1706</span>                if (timeout++ &gt; seconds) {<a name="line.1706"></a>
-<span class="sourceLineNo">1707</span>                    return false;<a name="line.1707"></a>
-<span class="sourceLineNo">1708</span>                }<a name="line.1708"></a>
-<span class="sourceLineNo">1709</span>            }<a name="line.1709"></a>
-<span class="sourceLineNo">1710</span>            try {<a name="line.1710"></a>
-<span class="sourceLineNo">1711</span>                Thread.sleep(100);<a name="line.1711"></a>
-<span class="sourceLineNo">1712</span>            } catch (final InterruptedException ignore) {<a name="line.1712"></a>
-<span class="sourceLineNo">1713</span>                // ignore exception<a name="line.1713"></a>
-<span class="sourceLineNo">1714</span>            } catch (final Exception ex) {<a name="line.1714"></a>
-<span class="sourceLineNo">1715</span>                break;<a name="line.1715"></a>
-<span class="sourceLineNo">1716</span>            }<a name="line.1716"></a>
-<span class="sourceLineNo">1717</span>        }<a name="line.1717"></a>
-<span class="sourceLineNo">1718</span>        return true;<a name="line.1718"></a>
-<span class="sourceLineNo">1719</span>    }<a name="line.1719"></a>
-<span class="sourceLineNo">1720</span><a name="line.1720"></a>
-<span class="sourceLineNo">1721</span>    //-----------------------------------------------------------------------<a name="line.1721"></a>
-<span class="sourceLineNo">1722</span>    /**<a name="line.1722"></a>
-<span class="sourceLineNo">1723</span>     * Reads the contents of a file into a String.<a name="line.1723"></a>
-<span class="sourceLineNo">1724</span>     * The file is always closed.<a name="line.1724"></a>
-<span class="sourceLineNo">1725</span>     *<a name="line.1725"></a>
-<span class="sourceLineNo">1726</span>     * @param file  the file to read, must not be {@code null}<a name="line.1726"></a>
-<span class="sourceLineNo">1727</span>     * @param encoding  the encoding to use, {@code null} means platform default<a name="line.1727"></a>
-<span class="sourceLineNo">1728</span>     * @return the file contents, never {@code null}<a name="line.1728"></a>
-<span class="sourceLineNo">1729</span>     * @throws IOException in case of an I/O error<a name="line.1729"></a>
-<span class="sourceLineNo">1730</span>     * @since 2.3<a name="line.1730"></a>
-<span class="sourceLineNo">1731</span>     */<a name="line.1731"></a>
-<span class="sourceLineNo">1732</span>    public static String readFileToString(final File file, final Charset encoding) throws IOException {<a name="line.1732"></a>
-<span class="sourceLineNo">1733</span>        InputStream in = null;<a name="line.1733"></a>
-<span class="sourceLineNo">1734</span>        try {<a name="line.1734"></a>
-<span class="sourceLineNo">1735</span>            in = openInputStream(file);<a name="line.1735"></a>
-<span class="sourceLineNo">1736</span>            return IOUtils.toString(in, Charsets.toCharset(encoding));<a name="line.1736"></a>
-<span class="sourceLineNo">1737</span>        } finally {<a name="line.1737"></a>
-<span class="sourceLineNo">1738</span>            IOUtils.closeQuietly(in);<a name="line.1738"></a>
-<span class="sourceLineNo">1739</span>        }<a name="line.1739"></a>
-<span class="sourceLineNo">1740</span>    }<a name="line.1740"></a>
-<span class="sourceLineNo">1741</span><a name="line.1741"></a>
-<span class="sourceLineNo">1742</span>    /**<a name="line.1742"></a>
-<span class="sourceLineNo">1743</span>     * Reads the contents of a file into a String. The file is always closed.<a name="line.1743"></a>
-<span class="sourceLineNo">1744</span>     *<a name="line.1744"></a>
-<span class="sourceLineNo">1745</span>     * @param file<a name="line.1745"></a>
-<span class="sourceLineNo">1746</span>     *            the file to read, must not be {@code null}<a name="line.1746"></a>
-<span class="sourceLineNo">1747</span>     * @param encoding<a name="line.1747"></a>
-<span class="sourceLineNo">1748</span>     *            the encoding to use, {@code null} means platform default<a name="line.1748"></a>
-<span class="sourceLineNo">1749</span>     * @return the file contents, never {@code null}<a name="line.1749"></a>
-<span class="sourceLineNo">1750</span>     * @throws IOException<a name="line.1750"></a>
-<span class="sourceLineNo">1751</span>     *             in case of an I/O error<a name="line.1751"></a>
-<span class="sourceLineNo">1752</span>     * @throws UnsupportedCharsetException<a name="line.1752"></a>
-<span class="sourceLineNo">1753</span>     *             thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not<a name="line.1753"></a>
-<span class="sourceLineNo">1754</span>     *             supported.<a name="line.1754"></a>
-<span class="sourceLineNo">1755</span>     * @since 2.3<a name="line.1755"></a>
-<span class="sourceLineNo">1756</span>     */<a name="line.1756"></a>
-<span class="sourceLineNo">1757</span>    public static String readFileToString(final File file, final String encoding) throws IOException {<a name="line.1757"></a>
-<span class="sourceLineNo">1758</span>        return readFileToString(file, Charsets.toCharset(encoding));<a name="line.1758"></a>
-<span class="sourceLineNo">1759</span>    }<a name="line.1759"></a>
-<span class="sourceLineNo">1760</span><a name="line.1760"></a>
-<span class="sourceLineNo">1761</span><a name="line.1761"></a>
-<span class="sourceLineNo">1762</span>    /**<a name="line.1762"></a>
-<span class="sourceLineNo">1763</span>     * Reads the contents of a file into a String using the default encoding for the VM.<a name="line.1763"></a>
-<span class="sourceLineNo">1764</span>     * The file is always closed.<a name="line.1764"></a>
-<span class="sourceLineNo">1765</span>     *<a name="line.1765"></a>
-<span class="sourceLineNo">1766</span>     * @param file  the file to read, must not be {@code null}<a name="line.1766"></a>
-<span class="sourceLineNo">1767</span>     * @return the file contents, never {@code null}<a name="line.1767"></a>
-<span class="sourceLineNo">1768</span>     * @throws IOException in case of an I/O error<a name="line.1768"></a>
-<span class="sourceLineNo">1769</span>     * @since 1.3.1<a name="line.1769"></a>
-<span class="sourceLineNo">1770</span>     * @deprecated 2.5 use {@link #readFileToString(File, Charset)} instead<a name="line.1770"></a>
-<span class="sourceLineNo">1771</span>     */<a name="line.1771"></a>
-<span class="sourceLineNo">1772</span>    @Deprecated<a name="line.1772"></a>
-<span class="sourceLineNo">1773</span>    public static String readFileToString(final File file) throws IOException {<a name="line.1773"></a>
-<span class="sourceLineNo">1774</span>        return readFileToString(file, Charset.defaultCharset());<a name="line.1774"></a>
-<span class="sourceLineNo">1775</span>    }<a name="line.1775"></a>
-<span class="sourceLineNo">1776</span><a name="line.1776"></a>
-<span class="sourceLineNo">1777</span>    /**<a name="line.1777"></a>
-<span class="sourceLineNo">1778</span>     * Reads the contents of a file into a byte array.<a name="line.1778"></a>
-<span class="sourceLineNo">1779</span>     * The file is always closed.<a name="line.1779"></a>
-<span class="sourceLineNo">1780</span>     *<a name="line.1780"></a>
-<span class="sourceLineNo">1781</span>     * @param file  the file to read, must not be {@code null}<a name="line.1781"></a>
-<span class="sourceLineNo">1782</span>     * @return the file contents, never {@code null}<a name="line.1782"></a>
-<span class="sourceLineNo">1783</span>     * @throws IOException in case of an I/O error<a name="line.1783"></a>
-<span class="sourceLineNo">1784</span>     * @since 1.1<a name="line.1784"></a>
-<span class="sourceLineNo">1785</span>     */<a name="line.1785"></a>
-<span class="sourceLineNo">1786</span>    public static byte[] readFileToByteArray(final File file) throws IOException {<a name="line.1786"></a>
-<span class="sourceLineNo">1787</span>        InputStream in = null;<a name="line.1787"></a>
-<span class="sourceLineNo">1788</span>        try {<a name="line.1788"></a>
-<span class="sourceLineNo">1789</span>            in = openInputStream(file);<a name="line.1789"></a>
-<span class="sourceLineNo">1790</span>            return IOUtils.toByteArray(in, file.length());<a name="line.1790"></a>
-<span class="sourceLineNo">1791</span>        } finally {<a name="line.1791"></a>
-<span class="sourceLineNo">1792</span>            IOUtils.closeQuietly(in);<a name="line.1792"></a>
-<span class="sourceLineNo">1793</span>        }<a name="line.1793"></a>
-<span class="sourceLineNo">1794</span>    }<a name="line.1794"></a>
-<span class="sourceLineNo">1795</span><a name="line.1795"></a>
-<span class="sourceLineNo">1796</span>    /**<a name="line.1796"></a>
-<span class="sourceLineNo">1797</span>     * Reads the contents of a file line by line to a List of Strings.<a name="line.1797"></a>
-<span class="sourceLineNo">1798</span>     * The file is always closed.<a name="line.1798"></a>
-<span class="sourceLineNo">1799</span>     *<a name="line.1799"></a>
-<span class="sourceLineNo">1800</span>     * @param file  the file to read, must not be {@code null}<a name="line.1800"></a>
-<span class="sourceLineNo">1801</span>     * @param encoding  the encoding to use, {@code null} means platform default<a name="line.1801"></a>
-<span class="sourceLineNo">1802</span>     * @return the list of Strings representing each line in the file, never {@code null}<a name="line.1802"></a>
-<span class="sourceLineNo">1803</span>     * @throws IOException in case of an I/O error<a name="line.1803"></a>
-<span class="sourceLineNo">1804</span>     * @since 2.3<a name="line.1804"></a>
-<span class="sourceLineNo">1805</span>     */<a name="line.1805"></a>
-<span class="sourceLineNo">1806</span>    public static List&lt;String&gt; readLines(final File file, final Charset encoding) throws IOException {<a name="line.1806"></a>
-<span class="sourceLineNo">1807</span>        InputStream in = null;<a name="line.1807"></a>
-<span class="sourceLineNo">1808</span>        try {<a name="line.1808"></a>
-<span class="sourceLineNo">1809</span>            in = openInputStream(file);<a name="line.1809"></a>
-<span class="sourceLineNo">1810</span>            return IOUtils.readLines(in, Charsets.toCharset(encoding));<a name="line.1810"></a>
-<span class="sourceLineNo">1811</span>        } finally {<a name="line.1811"></a>
-<span class="sourceLineNo">1812</span>            IOUtils.closeQuietly(in);<a name="line.1812"></a>
-<span class="sourceLineNo">1813</span>        }<a name="line.1813"></a>
-<span class="sourceLineNo">1814</span>    }<a name="line.1814"></a>
-<span class="sourceLineNo">1815</span><a name="line.1815"></a>
-<span class="sourceLineNo">1816</span>    /**<a name="line.1816"></a>
-<span class="sourceLineNo">1817</span>     * Reads the contents of a file line by line to a List of Strings. The file is always closed.<a name="line.1817"></a>
-<span class="sourceLineNo">1818</span>     *<a name="line.1818"></a>
-<span class="sourceLineNo">1819</span>     * @param file<a name="line.1819"></a>
-<span class="sourceLineNo">1820</span>     *            the file to read, must not be {@code null}<a name="line.1820"></a>
-<span class="sourceLineNo">1821</span>     * @param encoding<a name="line.1821"></a>
-<span class="sourceLineNo">1822</span>     *            the encoding to use, {@code null} means platform default<a name="line.1822"></a>
-<span class="sourceLineNo">1823</span>     * @return the list of Strings representing each line in the file, never {@code null}<a name="line.1823"></a>
-<span class="sourceLineNo">1824</span>     * @throws IOException<a name="line.1824"></a>
-<span class="sourceLineNo">1825</span>     *             in case of an I/O error<a name="line.1825"></a>
-<span class="sourceLineNo">1826</span>     * @throws UnsupportedCharsetException<a name="line.1826"></a>
-<span class="sourceLineNo">1827</span>     *             thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not<a name="line.1827"></a>
-<span class="sourceLineNo">1828</span>     *             supported.<a name="line.1828"></a>
-<span class="sourceLineNo">1829</span>     * @since 1.1<a name="line.1829"></a>
-<span class="sourceLineNo">1830</span>     */<a name="line.1830"></a>
-<span class="sourceLineNo">1831</span>    public static List&lt;String&gt; readLines(final File file, final String encoding) throws IOException {<a name="line.1831"></a>
-<span class="sourceLineNo">1832</span>        return readLines(file, Charsets.toCharset(encoding));<a name="line.1832"></a>
-<span class="sourceLineNo">1833</span>    }<a name="line.1833"></a>
-<span class="sourceLineNo">1834</span><a name="line.1834"></a>
-<span class="sourceLineNo">1835</span>    /**<a name="line.1835"></a>
-<span class="sourceLineNo">1836</span>     * Reads the contents of a file line by line to a List of Strings using the default encoding for the VM.<a name="line.1836"></a>
-<span class="sourceLineNo">1837</span>     * The file is always closed.<a name="line.1837"></a>
-<span class="sourceLineNo">1838</span>     *<a name="line.1838"></a>
-<span class="sourceLineNo">1839</span>     * @param file  the file to read, must not be {@code null}<a name="line.1839"></a>
-<span class="sourceLineNo">1840</span>     * @return the list of Strings representing each line in the file, never {@code null}<a name="line.1840"></a>
-<span class="sourceLineNo">1841</span>     * @throws IOException in case of an I/O error<a name="line.1841"></a>
-<span class="sourceLineNo">1842</span>     * @since 1.3<a name="line.1842"></a>
-<span class="sourceLineNo">1843</span>     * @deprecated 2.5 use {@link #readLines(File, Charset)} instead<a name="line.1843"></a>
-<span class="sourceLineNo">1844</span>     */<a name="line.1844"></a>
-<span class="sourceLineNo">1845</span>    @Deprecated<a name="line.1845"></a>
-<span class="sourceLineNo">1846</span>    public static List&lt;String&gt; readLines(final File file) throws IOException {<a name="line.1846"></a>
-<span class="sourceLineNo">1847</span>        return readLines(file, Charset.defaultCharset());<a name="line.1847"></a>
-<span class="sourceLineNo">1848</span>    }<a name="line.1848"></a>
-<span class="sourceLineNo">1849</span><a name="line.1849"></a>
-<span class="sourceLineNo">1850</span>    /**<a name="line.1850"></a>
-<span class="sourceLineNo">1851</span>     * Returns an Iterator for the lines in a &lt;code&gt;File&lt;/code&gt;.<a name="line.1851"></a>
-<span class="sourceLineNo">1852</span>     * &lt;p&gt;<a name="line.1852"></a>
-<span class="sourceLineNo">1853</span>     * This method opens an &lt;code&gt;InputStream&lt;/code&gt; for the file.<a name="line.1853"></a>
-<span class="sourceLineNo">1854</span>     * When you have finished with the iterator you should close the stream<a name="line.1854"></a>
-<span class="sourceLineNo">1855</span>     * to free internal resources. This can be done by calling the<a name="line.1855"></a>
-<span class="sourceLineNo">1856</span>     * {@link LineIterator#close()} or<a name="line.1856"></a>
-<span class="sourceLineNo">1857</span>     * {@link LineIterator#closeQuietly(LineIterator)} method.<a name="line.1857"></a>
-<span class="sourceLineNo">1858</span>     * &lt;p&gt;<a name="line.1858"></a>
-<span class="sourceLineNo">1859</span>     * The recommended usage pattern is:<a name="line.1859"></a>
-<span class="sourceLineNo">1860</span>     * &lt;pre&gt;<a name="line.1860"></a>
-<span class="sourceLineNo">1861</span>     * LineIterator it = FileUtils.lineIterator(file, "UTF-8");<a name="line.1861"></a>
-<span class="sourceLineNo">1862</span>     * try {<a name="line.1862"></a>
-<span class="sourceLineNo">1863</span>     *   while (it.hasNext()) {<a name="line.1863"></a>
-<span class="sourceLineNo">1864</span>     *     String line = it.nextLine();<a name="line.1864"></a>
-<span class="sourceLineNo">1865</span>     *     /// do something with line<a name="line.1865"></a>
-<span class="sourceLineNo">1866</span>     *   }<a name="line.1866"></a>
-<span class="sourceLineNo">1867</span>     * } finally {<a name="line.1867"></a>
-<span class="sourceLineNo">1868</span>     *   LineIterator.closeQuietly(iterator);<a name="line.1868"></a>
-<span class="sourceLineNo">1869</span>     * }<a name="line.1869"></a>
-<span class="sourceLineNo">1870</span>     * &lt;/pre&gt;<a name="line.1870"></a>
-<span class="sourceLineNo">1871</span>     * &lt;p&gt;<a name="line.1871"></a>
-<span class="sourceLineNo">1872</span>     * If an exception occurs during the creation of the iterator, the<a name="line.1872"></a>
-<span class="sourceLineNo">1873</span>     * underlying stream is closed.<a name="line.1873"></a>
-<span class="sourceLineNo">1874</span>     *<a name="line.1874"></a>
-<span class="sourceLineNo">1875</span>     * @param file  the file to open for input, must not be {@code null}<a name="line.1875"></a>
-<span class="sourceLineNo">1876</span>     * @param encoding  the encoding to use, {@code null} means platform default<a name="line.1876"></a>
-<span class="sourceLineNo">1877</span>     * @return an Iterator of the lines in the file, never {@code null}<a name="line.1877"></a>
-<span class="sourceLineNo">1878</span>     * @throws IOException in case of an I/O error (file closed)<a name="line.1878"></a>
-<span class="sourceLineNo">1879</span>     * @since 1.2<a name="line.1879"></a>
-<span class="sourceLineNo">1880</span>     */<a name="line.1880"></a>
-<span class="sourceLineNo">1881</span>    public static LineIterator lineIterator(final File file, final String encoding) throws IOException {<a name="line.1881"></a>
-<span class="sourceLineNo">1882</span>        InputStream in = null;<a name="line.1882"></a>
-<span class="sourceLineNo">1883</span>        try {<a name="line.1883"></a>
-<span class="sourceLineNo">1884</span>            in = openInputStream(file);<a name="line.1884"></a>
-<span class="sourceLineNo">1885</span>            return IOUtils.lineIterator(in, encoding);<a name="line.1885"></a>
-<span class="sourceLineNo">1886</span>        } catch (final IOException ex) {<a name="line.1886"></a>
+<span class="sourceLineNo">1649</span>    /**<a name="line.1649"></a>
+<span class="sourceLineNo">1650</span>     * Cleans a directory without deleting it.<a name="line.1650"></a>
+<span class="sourceLineNo">1651</span>     *<a name="line.1651"></a>
+<span class="sourceLineNo">1652</span>     * @param directory directory to clean<a name="line.1652"></a>
+<span class="sourceLineNo">1653</span>     * @throws IOException in case cleaning is unsuccessful<a name="line.1653"></a>
+<span class="sourceLineNo">1654</span>     */<a name="line.1654"></a>
+<span class="sourceLineNo">1655</span>    public static void cleanDirectory(final File directory) throws IOException {<a name="line.1655"></a>
+<span class="sourceLineNo">1656</span>        if (!directory.exists()) {<a name="line.1656"></a>
+<span class="sourceLineNo">1657</span>            final String message = directory + " does not exist";<a name="line.1657"></a>
+<span class="sourceLineNo">1658</span>            throw new IllegalArgumentException(message);<a name="line.1658"></a>
+<span class="sourceLineNo">1659</span>        }<a name="line.1659"></a>
+<span class="sourceLineNo">1660</span><a name="line.1660"></a>
+<span class="sourceLineNo">1661</span>        if (!directory.isDirectory()) {<a name="line.1661"></a>
+<span class="sourceLineNo">1662</span>            final String message = directory + " is not a directory";<a name="line.1662"></a>
+<span class="sourceLineNo">1663</span>            throw new IllegalArgumentException(message);<a name="line.1663"></a>
+<span class="sourceLineNo">1664</span>        }<a name="line.1664"></a>
+<span class="sourceLineNo">1665</span><a name="line.1665"></a>
+<span class="sourceLineNo">1666</span>        final File[] files = directory.listFiles();<a name="line.1666"></a>
+<span class="sourceLineNo">1667</span>        if (files == null) {  // null if security restricted<a name="line.1667"></a>
+<span class="sourceLineNo">1668</span>            throw new IOException("Failed to list contents of " + directory);<a name="line.1668"></a>
+<span class="sourceLineNo">1669</span>        }<a name="line.1669"></a>
+<span class="sourceLineNo">1670</span><a name="line.1670"></a>
+<span class="sourceLineNo">1671</span>        IOException exception = null;<a name="line.1671"></a>
+<span class="sourceLineNo">1672</span>        for (final File file : files) {<a name="line.1672"></a>
+<span class="sourceLineNo">1673</span>            try {<a name="line.1673"></a>
+<span class="sourceLineNo">1674</span>                forceDelete(file);<a name="line.1674"></a>
+<span class="sourceLineNo">1675</span>            } catch (final IOException ioe) {<a name="line.1675"></a>
+<span class="sourceLineNo">1676</span>                exception = ioe;<a name="line.1676"></a>
+<span class="sourceLineNo">1677</span>            }<a name="line.1677"></a>
+<span class="sourceLineNo">1678</span>        }<a name="line.1678"></a>
+<span class="sourceLineNo">1679</span><a name="line.1679"></a>
+<span class="sourceLineNo">1680</span>        if (null != exception) {<a name="line.1680"></a>
+<span class="sourceLineNo">1681</span>            throw exception;<a name="line.1681"></a>
+<span class="sourceLineNo">1682</span>        }<a name="line.1682"></a>
+<span class="sourceLineNo">1683</span>    }<a name="line.1683"></a>
+<span class="sourceLineNo">1684</span><a name="line.1684"></a>
+<span class="sourceLineNo">1685</span>    //-----------------------------------------------------------------------<a name="line.1685"></a>
+<span class="sourceLineNo">1686</span>    /**<a name="line.1686"></a>
+<span class="sourceLineNo">1687</span>     * Waits for NFS to propagate a file creation, imposing a timeout.<a name="line.1687"></a>
+<span class="sourceLineNo">1688</span>     * &lt;p&gt;<a name="line.1688"></a>
+<span class="sourceLineNo">1689</span>     * This method repeatedly tests {@link File#exists()} until it returns<a name="line.1689"></a>
+<span class="sourceLineNo">1690</span>     * true up to the maximum time specified in seconds.<a name="line.1690"></a>
+<span class="sourceLineNo">1691</span>     *<a name="line.1691"></a>
+<span class="sourceLineNo">1692</span>     * @param file  the file to check, must not be {@code null}<a name="line.1692"></a>
+<span class="sourceLineNo">1693</span>     * @param seconds  the maximum time in seconds to wait<a name="line.1693"></a>
+<span class="sourceLineNo">1694</span>     * @return true if file exists<a name="line.1694"></a>
+<span class="sourceLineNo">1695</span>     * @throws NullPointerException if the file is {@code null}<a name="line.1695"></a>
+<span class="sourceLineNo">1696</span>     */<a name="line.1696"></a>
+<span class="sourceLineNo">1697</span>    public static boolean waitFor(final File file, final int seconds) {<a name="line.1697"></a>
+<span class="sourceLineNo">1698</span>        int timeout = 0;<a name="line.1698"></a>
+<span class="sourceLineNo">1699</span>        int tick = 0;<a name="line.1699"></a>
+<span class="sourceLineNo">1700</span>        while (!file.exists()) {<a name="line.1700"></a>
+<span class="sourceLineNo">1701</span>            if (tick++ &gt;= 10) {<a name="line.1701"></a>
+<span class="sourceLineNo">1702</span>                tick = 0;<a name="line.1702"></a>
+<span class="sourceLineNo">1703</span>                if (timeout++ &gt; seconds) {<a name="line.1703"></a>
+<span class="sourceLineNo">1704</span>                    return false;<a name="line.1704"></a>
+<span class="sourceLineNo">1705</span>                }<a name="line.1705"></a>
+<span class="sourceLineNo">1706</span>            }<a name="line.1706"></a>
+<span class="sourceLineNo">1707</span>            try {<a name="line.1707"></a>
+<span class="sourceLineNo">1708</span>                Thread.sleep(100);<a name="line.1708"></a>
+<span class="sourceLineNo">1709</span>            } catch (final InterruptedException ignore) {<a name="line.1709"></a>
+<span class="sourceLineNo">1710</span>                // ignore exception<a name="line.1710"></a>
+<span class="sourceLineNo">1711</span>            } catch (final Exception ex) {<a name="line.1711"></a>
+<span class="sourceLineNo">1712</span>                break;<a name="line.1712"></a>
+<span class="sourceLineNo">1713</span>            }<a name="line.1713"></a>
+<span class="sourceLineNo">1714</span>        }<a name="line.1714"></a>
+<span class="sourceLineNo">1715</span>        return true;<a name="line.1715"></a>
+<span class="sourceLineNo">1716</span>    }<a name="line.1716"></a>
+<span class="sourceLineNo">1717</span><a name="line.1717"></a>
+<span class="sourceLineNo">1718</span>    //-----------------------------------------------------------------------<a name="line.1718"></a>
+<span class="sourceLineNo">1719</span>    /**<a name="line.1719"></a>
+<span class="sourceLineNo">1720</span>     * Reads the contents of a file into a String.<a name="line.1720"></a>
+<span class="sourceLineNo">1721</span>     * The file is always closed.<a name="line.1721"></a>
+<span class="sourceLineNo">1722</span>     *<a name="line.1722"></a>
+<span class="sourceLineNo">1723</span>     * @param file  the file to read, must not be {@code null}<a name="line.1723"></a>
+<span class="sourceLineNo">1724</span>     * @param encoding  the encoding to use, {@code null} means platform default<a name="line.1724"></a>
+<span class="sourceLineNo">1725</span>     * @return the file contents, never {@code null}<a name="line.1725"></a>
+<span class="sourceLineNo">1726</span>     * @throws IOException in case of an I/O error<a name="line.1726"></a>
+<span class="sourceLineNo">1727</span>     * @since 2.3<a name="line.1727"></a>
+<span class="sourceLineNo">1728</span>     */<a name="line.1728"></a>
+<span class="sourceLineNo">1729</span>    public static String readFileToString(final File file, final Charset encoding) throws IOException {<a name="line.1729"></a>
+<span class="sourceLineNo">1730</span>        InputStream in = null;<a name="line.1730"></a>
+<span class="sourceLineNo">1731</span>        try {<a name="line.1731"></a>
+<span class="sourceLineNo">1732</span>            in = openInputStream(file);<a name="line.1732"></a>
+<span class="sourceLineNo">1733</span>            return IOUtils.toString(in, Charsets.toCharset(encoding));<a name="line.1733"></a>
+<span class="sourceLineNo">1734</span>        } finally {<a name="line.1734"></a>
+<span class="sourceLineNo">1735</span>            IOUtils.closeQuietly(in);<a name="line.1735"></a>
+<span class="sourceLineNo">1736</span>        }<a name="line.1736"></a>
+<span class="sourceLineNo">1737</span>    }<a name="line.1737"></a>
+<span class="sourceLineNo">1738</span><a name="line.1738"></a>
+<span class="sourceLineNo">1739</span>    /**<a name="line.1739"></a>
+<span class="sourceLineNo">1740</span>     * Reads the contents of a file into a String. The file is always closed.<a name="line.1740"></a>
+<span class="sourceLineNo">1741</span>     *<a name="line.1741"></a>
+<span class="sourceLineNo">1742</span>     * @param file<a name="line.1742"></a>
+<span class="sourceLineNo">1743</span>     *            the file to read, must not be {@code null}<a name="line.1743"></a>
+<span class="sourceLineNo">1744</span>     * @param encoding<a name="line.1744"></a>
+<span class="sourceLineNo">1745</span>     *            the encoding to use, {@code null} means platform default<a name="line.1745"></a>
+<span class="sourceLineNo">1746</span>     * @return the file contents, never {@code null}<a name="line.1746"></a>
+<span class="sourceLineNo">1747</span>     * @throws IOException<a name="line.1747"></a>
+<span class="sourceLineNo">1748</span>     *             in case of an I/O error<a name="line.1748"></a>
+<span class="sourceLineNo">1749</span>     * @throws UnsupportedCharsetException<a name="line.1749"></a>
+<span class="sourceLineNo">1750</span>     *             thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not<a name="line.1750"></a>
+<span class="sourceLineNo">1751</span>     *             supported.<a name="line.1751"></a>
+<span class="sourceLineNo">1752</span>     * @since 2.3<a name="line.1752"></a>
+<span class="sourceLineNo">1753</span>     */<a name="line.1753"></a>
+<span class="sourceLineNo">1754</span>    public static String readFileToString(final File file, final String encoding) throws IOException {<a name="line.1754"></a>
+<span class="sourceLineNo">1755</span>        return readFileToString(file, Charsets.toCharset(encoding));<a name="line.1755"></a>
+<span class="sourceLineNo">1756</span>    }<a name="line.1756"></a>
+<span class="sourceLineNo">1757</span><a name="line.1757"></a>
+<span class="sourceLineNo">1758</span><a name="line.1758"></a>
+<span class="sourceLineNo">1759</span>    /**<a name="line.1759"></a>
+<span class="sourceLineNo">1760</span>     * Reads the contents of a file into a String using the default encoding for the VM.<a name="line.1760"></a>
+<span class="sourceLineNo">1761</span>     * The file is always closed.<a name="line.1761"></a>
+<span class="sourceLineNo">1762</span>     *<a name="line.1762"></a>
+<span class="sourceLineNo">1763</span>     * @param file  the file to read, must not be {@code null}<a name="line.1763"></a>
+<span class="sourceLineNo">1764</span>     * @return the file contents, never {@code null}<a name="line.1764"></a>
+<span class="sourceLineNo">1765</span>     * @throws IOException in case of an I/O error<a name="line.1765"></a>
+<span class="sourceLineNo">1766</span>     * @since 1.3.1<a name="line.1766"></a>
+<span class="sourceLineNo">1767</span>     * @deprecated 2.5 use {@link #readFileToString(File, Charset)} instead<a name="line.1767"></a>
+<span class="sourceLineNo">1768</span>     */<a name="line.1768"></a>
+<span class="sourceLineNo">1769</span>    @Deprecated<a name="line.1769"></a>
+<span class="sourceLineNo">1770</span>    public static String readFileToString(final File file) throws IOException {<a name="line.1770"></a>
+<span class="sourceLineNo">1771</span>        return readFileToString(file, Charset.defaultCharset());<a name="line.1771"></a>
+<span class="sourceLineNo">1772</span>    }<a name="line.1772"></a>
+<span class="sourceLineNo">1773</span><a name="line.1773"></a>
+<span class="sourceLineNo">1774</span>    /**<a name="line.1774"></a>
+<span class="sourceLineNo">1775</span>     * Reads the contents of a file into a byte array.<a name="line.1775"></a>
+<span class="sourceLineNo">1776</span>     * The file is always closed.<a name="line.1776"></a>
+<span class="sourceLineNo">1777</span>     *<a name="line.1777"></a>
+<span class="sourceLineNo">1778</span>     * @param file  the file to read, must not be {@code null}<a name="line.1778"></a>
+<span class="sourceLineNo">1779</span>     * @return the file contents, never {@code null}<a name="line.1779"></a>
+<span class="sourceLineNo">1780</span>     * @throws IOException in case of an I/O error<a name="line.1780"></a>
+<span class="sourceLineNo">1781</span>     * @since 1.1<a name="line.1781"></a>
+<span class="sourceLineNo">1782</span>     */<a name="line.1782"></a>
+<span class="sourceLineNo">1783</span>    public static byte[] readFileToByteArray(final File file) throws IOException {<a name="line.1783"></a>
+<span class="sourceLineNo">1784</span>        InputStream in = null;<a name="line.1784"></a>
+<span class="sourceLineNo">1785</span>        try {<a name="line.1785"></a>
+<span class="sourceLineNo">1786</span>            in = openInputStream(file);<a name="line.1786"></a>
+<span class="sourceLineNo">1787</span>            return IOUtils.toByteArray(in, file.length());<a name="line.1787"></a>
+<span class="sourceLineNo">1788</span>        } finally {<a name="line.1788"></a>
+<span class="sourceLineNo">1789</span>            IOUtils.closeQuietly(in);<a name="line.1789"></a>
+<span class="sourceLineNo">1790</span>        }<a name="line.1790"></a>
+<span class="sourceLineNo">1791</span>    }<a name="line.1791"></a>
+<span class="sourceLineNo">1792</span><a name="line.1792"></a>
+<span class="sourceLineNo">1793</span>    /**<a name="line.1793"></a>
+<span class="sourceLineNo">1794</span>     * Reads the contents of a file line by line to a List of Strings.<a name="line.1794"></a>
+<span class="sourceLineNo">1795</span>     * The file is always closed.<a name="line.1795"></a>
+<span class="sourceLineNo">1796</span>     *<a name="line.1796"></a>
+<span class="sourceLineNo">1797</span>     * @param file  the file to read, must not be {@code null}<a name="line.1797"></a>
+<span class="sourceLineNo">1798</span>     * @param encoding  the encoding to use, {@code null} means platform default<a name="line.1798"></a>
+<span class="sourceLineNo">1799</span>     * @return the list of Strings representing each line in the file, never {@code null}<a name="line.1799"></a>
+<span class="sourceLineNo">1800</span>     * @throws IOException in case of an I/O error<a name="line.1800"></a>
+<span class="sourceLineNo">1801</span>     * @since 2.3<a name="line.1801"></a>
+<span class="sourceLineNo">1802</span>     */<a name="line.1802"></a>
+<span class="sourceLineNo">1803</span>    public static List&lt;String&gt; readLines(final File file, final Charset encoding) throws IOException {<a name="line.1803"></a>
+<span class="sourceLineNo">1804</span>        InputStream in = null;<a name="line.1804"></a>
+<span class="sourceLineNo">1805</span>        try {<a name="line.1805"></a>
+<span class="sourceLineNo">1806</span>            in = openInputStream(file);<a name="line.1806"></a>
+<span class="sourceLineNo">1807</span>            return IOUtils.readLines(in, Charsets.toCharset(encoding));<a name="line.1807"></a>
+<span class="sourceLineNo">1808</span>        } finally {<a name="line.1808"></a>
+<span class="sourceLineNo">1809</span>            IOUtils.closeQuietly(in);<a name="line.1809"></a>
+<span class="sourceLineNo">1810</span>        }<a name="line.1810"></a>
+<span class="sourceLineNo">1811</span>    }<a name="line.1811"></a>
+<span class="sourceLineNo">1812</span><a name="line.1812"></a>
+<span class="sourceLineNo">1813</span>    /**<a name="line.1813"></a>
+<span class="sourceLineNo">1814</span>     * Reads the contents of a file line by line to a List of Strings. The file is always closed.<a name="line.1814"></a>
+<span class="sourceLineNo">1815</span>     *<a name="line.1815"></a>
+<span class="sourceLineNo">1816</span>     * @param file<a name="line.1816"></a>
+<span class="sourceLineNo">1817</span>     *            the file to read, must not be {@code null}<a name="line.1817"></a>
+<span class="sourceLineNo">1818</span>     * @param encoding<a name="line.1818"></a>
+<span class="sourceLineNo">1819</span>     *            the encoding to use, {@code null} means platform default<a name="line.1819"></a>
+<span class="sourceLineNo">1820</span>     * @return the list of Strings representing each line in the file, never {@code null}<a name="line.1820"></a>
+<span class="sourceLineNo">1821</span>     * @throws IOException<a name="line.1821"></a>
+<span class="sourceLineNo">1822</span>     *             in case of an I/O error<a name="line.1822"></a>
+<span class="sourceLineNo">1823</span>     * @throws UnsupportedCharsetException<a name="line.1823"></a>
+<span class="sourceLineNo">1824</span>     *             thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not<a name="line.1824"></a>
+<span class="sourceLineNo">1825</span>     *             supported.<a name="line.1825"></a>
+<span class="sourceLineNo">1826</span>     * @since 1.1<a name="line.1826"></a>
+<span class="sourceLineNo">1827</span>     */<a name="line.1827"></a>
+<span class="sourceLineNo">1828</span>    public static List&lt;String&gt; readLines(final File file, final String encoding) throws IOException {<a name="line.1828"></a>
+<span class="sourceLineNo">1829</span>        return readLines(file, Charsets.toCharset(encoding));<a name="line.1829"></a>
+<span class="sourceLineNo">1830</span>    }<a name="line.1830"></a>
+<span class="sourceLineNo">1831</span><a name="line.1831"></a>
+<span class="sourceLineNo">1832</span>    /**<a name="line.1832"></a>
+<span class="sourceLineNo">1833</span>     * Reads the contents of a file line by line to a List of Strings using the default encoding for the VM.<a name="line.1833"></a>
+<span class="sourceLineNo">1834</span>     * The file is always closed.<a name="line.1834"></a>
+<span class="sourceLineNo">1835</span>     *<a name="line.1835"></a>
+<span class="sourceLineNo">1836</span>     * @param file  the file to read, must not be {@code null}<a name="line.1836"></a>
+<span class="sourceLineNo">1837</span>     * @return the list of Strings representing each line in the file, never {@code null}<a name="line.1837"></a>
+<span class="sourceLineNo">1838</span>     * @throws IOException in case of an I/O error<a name="line.1838"></a>
+<span class="sourceLineNo">1839</span>     * @since 1.3<a name="line.1839"></a>
+<span class="sourceLineNo">1840</span>     * @deprecated 2.5 use {@link #readLines(File, Charset)} instead<a name="line.1840"></a>
+<span class="sourceLineNo">1841</span>     */<a name="line.1841"></a>
+<span class="sourceLineNo">1842</span>    @Deprecated<a name="line.1842"></a>
+<span class="sourceLineNo">1843</span>    public static List&lt;String&gt; readLines(final File file) throws IOException {<a name="line.1843"></a>
+<span class="sourceLineNo">1844</span>        return readLines(file, Charset.defaultCharset());<a name="line.1844"></a>
+<span class="sourceLineNo">1845</span>    }<a name="line.1845"></a>
+<span class="sourceLineNo">1846</span><a name="line.1846"></a>
+<span class="sourceLineNo">1847</span>    /**<a name="line.1847"></a>
+<span class="sourceLineNo">1848</span>     * Returns an Iterator for the lines in a &lt;code&gt;File&lt;/code&gt;.<a name="line.1848"></a>
+<span class="sourceLineNo">1849</span>     * &lt;p&gt;<a name="line.1849"></a>
+<span class="sourceLineNo">1850</span>     * This method opens an &lt;code&gt;InputStream&lt;/code&gt; for the file.<a name="line.1850"></a>
+<span class="sourceLineNo">1851</span>     * When you have finished with the iterator you should close the stream<a name="line.1851"></a>
+<span class="sourceLineNo">1852</span>     * to free internal resources. This can be done by calling the<a name="line.1852"></a>
+<span class="sourceLineNo">1853</span>     * {@link LineIterator#close()} or<a name="line.1853"></a>
+<span class="sourceLineNo">1854</span>     * {@link LineIterator#closeQuietly(LineIterator)} method.<a name="line.1854"></a>
+<span class="sourceLineNo">1855</span>     * &lt;p&gt;<a name="line.1855"></a>
+<span class="sourceLineNo">1856</span>     * The recommended usage pattern is:<a name="line.1856"></a>
+<span class="sourceLineNo">1857</span>     * &lt;pre&gt;<a name="line.1857"></a>
+<span class="sourceLineNo">1858</span>     * LineIterator it = FileUtils.lineIterator(file, "UTF-8");<a name="line.1858"></a>
+<span class="sourceLineNo">1859</span>     * try {<a name="line.1859"></a>
+<span class="sourceLineNo">1860</span>     *   while (it.hasNext()) {<a name="line.1860"></a>
+<span class="sourceLineNo">1861</span>     *     String line = it.nextLine();<a name="line.1861"></a>
+<span class="sourceLineNo">1862</span>     *     /// do something with line<a name="line.1862"></a>
+<span class="sourceLineNo">1863</span>     *   }<a name="line.1863"></a>
+<span class="sourceLineNo">1864</span>     * } finally {<a name="line.1864"></a>
+<span class="sourceLineNo">1865</span>     *   LineIterator.closeQuietly(iterator);<a name="line.1865"></a>
+<span class="sourceLineNo">1866</span>     * }<a name="line.1866"></a>
+<span class="sourceLineNo">1867</span>     * &lt;/pre&gt;<a name="line.1867"></a>
+<span class="sourceLineNo">1868</span>     * &lt;p&gt;<a name="line.1868"></a>
+<span class="sourceLineNo">1869</span>     * If an exception occurs during the creation of the iterator, the<a name="line.1869"></a>
+<span class="sourceLineNo">1870</span>     * underlying stream is closed.<a name="line.1870"></a>
+<span class="sourceLineNo">1871</span>     *<a name="line.1871"></a>
+<span class="sourceLineNo">1872</span>     * @param file  the file to open for input, must not be {@code null}<a name="line.1872"></a>
+<span class="sourceLineNo">1873</span>     * @param encoding  the encoding to use, {@code null} means platform default<a name="line.1873"></a>
+<span class="sourceLineNo">1874</span>     * @return an Iterator of the lines in the file, never {@code null}<a name="line.1874"></a>
+<span class="sourceLineNo">1875</span>     * @throws IOException in case of an I/O error (file closed)<a name="line.1875"></a>
+<span class="sourceLineNo">1876</span>     * @since 1.2<a name="line.1876"></a>
+<span class="sourceLineNo">1877</span>     */<a name="line.1877"></a>
+<span class="sourceLineNo">1878</span>    public static LineIterator lineIterator(final File file, final String encoding) throws IOException {<a name="line.1878"></a>
+<span class="sourceLineNo">1879</span>        InputStream in = null;<a name="line.1879"></a>
+<span class="sourceLineNo">1880</span>        try {<a name="line.1880"></a>
+<span class="sourceLineNo">1881</span>            in = openInputStream(file);<a name="line.1881"></a>
+<span class="sourceLineNo">1882</span>            return IOUtils.lineIterator(in, encoding);<a name="line.1882"></a>
+<span class="sourceLineNo">1883</span>        } catch (final IOException ex) {<a name="line.1883"></a>
+<span class="sourceLineNo">1884</span>            IOUtils.closeQuietly(in);<a name="line.1884"></a>
+<span class="sourceLineNo">1885</span>            throw ex;<a name="line.1885"></a>
+<span class="sourceLineNo">1886</span>        } catch (final RuntimeException ex) {<a name="line.1886"></a>
 <span class="sourceLineNo">1887</span>            IOUtils.closeQuietly(in);<a name="line.1887"></a>
 <span class="sourceLineNo">1888</span>            throw ex;<a name="line.1888"></a>
-<span class="sourceLineNo">1889</span>        } catch (final RuntimeException ex) {<a name="line.1889"></a>
-<span class="sourceLineNo">1890</span>            IOUtils.closeQuietly(in);<a name="line.1890"></a>
-<span class="sourceLineNo">1891</span>            throw ex;<a name="line.1891"></a>
-<span class="sourceLineNo">1892</span>        }<a name="line.1892"></a>
-<span class="sourceLineNo">1893</span>    }<a name="line.1893"></a>
-<span class="sourceLineNo">1894</span><a name="line.1894"></a>
-<span class="sourceLineNo">1895</span>    /**<a name="line.1895"></a>
-<span class="sourceLineNo">1896</span>     * Returns an Iterator for the lines in a &lt;code&gt;File&lt;/code&gt; using the default encoding for the VM.<a name="line.1896"></a>
-<span class="sourceLineNo">1897</span>     *<a name="line.1897"></a>
-<span class="sourceLineNo">1898</span>     * @param file  the file to open for input, must not be {@code null}<a name="line.1898"></a>
-<span class="sourceLineNo">1899</span>     * @return an Iterator of the lines in the file, never {@code null}<a name="line.1899"></a>
-<span class="sourceLineNo">1900</span>     * @throws IOException in case of an I/O error (file closed)<a name="line.1900"></a>
-<span class="sourceLineNo">1901</span>     * @since 1.3<a name="line.1901"></a>
-<span class="sourceLineNo">1902</span>     * @see #lineIterator(File, String)<a name="line.1902"></a>
-<span class="sourceLineNo">1903</span>     */<a name="line.1903"></a>
-<span class="sourceLineNo">1904</span>    public static LineIterator lineIterator(final File file) throws IOException {<a name="line.1904"></a>
-<span class="sourceLineNo">1905</span>        return lineIterator(file, null);<a name="line.1905"></a>
-<span class="sourceLineNo">1906</span>    }<a name="line.1906"></a>
-<span class="sourceLineNo">1907</span><a name="line.1907"></a>
-<span class="sourceLineNo">1908</span>    //-----------------------------------------------------------------------<a name="line.1908"></a>
-<span class="sourceLineNo">1909</span>    /**<a name="line.1909"></a>
-<span class="sourceLineNo">1910</span>     * Writes a String to a file creating the file if it does not exist.<a name="line.1910"></a>
+<span class="sourceLineNo">1889</span>        }<a name="line.1889"></a>
+<span class="sourceLineNo">1890</span>    }<a name="line.1890"></a>
+<span class="sourceLineNo">1891</span><a name="line.1891"></a>
+<span class="sourceLineNo">1892</span>    /**<a name="line.1892"></a>
+<span class="sourceLineNo">1893</span>     * Returns an Iterator for the lines in a &lt;code&gt;File&lt;/code&gt; using the default encoding for the VM.<a name="line.1893"></a>
+<span class="sourceLineNo">1894</span>     *<a name="line.1894"></a>
+<span class="sourceLineNo">1895</span>     * @param file  the file to open for input, must not be {@code null}<a name="line.1895"></a>
+<span class="sourceLineNo">1896</span>     * @return an Iterator of the lines in the file, never {@code null}<a name="line.1896"></a>
+<span class="sourceLineNo">1897</span>     * @throws IOException in case of an I/O error (file closed)<a name="line.1897"></a>
+<span class="sourceLineNo">1898</span>     * @since 1.3<a name="line.1898"></a>
+<span class="sourceLineNo">1899</span>     * @see #lineIterator(File, String)<a name="line.1899"></a>
+<span class="sourceLineNo">1900</span>     */<a name="line.1900"></a>
+<span class="sourceLineNo">1901</span>    public static LineIterator lineIterator(final File file) throws IOException {<a name="line.1901"></a>
+<span class="sourceLineNo">1902</span>        return lineIterator(file, null);<a name="line.1902"></a>
+<span class="sourceLineNo">1903</span>    }<a name="line.1903"></a>
+<span class="sourceLineNo">1904</span><a name="line.1904"></a>
+<span class="sourceLineNo">1905</span>    //-----------------------------------------------------------------------<a name="line.1905"></a>
+<span class="sourceLineNo">1906</span>    /**<a name="line.1906"></a>
+<span class="sourceLineNo">1907</span>     * Writes a String to a file creating the file if it does not exist.<a name="line.1907"></a>
+<span class="sourceLineNo">1908</span>     *<a name="line.1908"></a>
+<span class="sourceLineNo">1909</span>     * NOTE: As from v1.3, the parent directories of the file will be created<a name="line.1909"></a>
+<span class="sourceLineNo">1910</span>     * if they do not exist.<a name="line.1910"></a>
 <span class="sourceLineNo">1911</span>     *<a name="line.1911"></a>
-<span class="sourceLineNo">1912</span>     * NOTE: As from v1.3, the parent directories of the file will be created<a name="line.1912"></a>
-<span class="sourceLineNo">1913</span>     * if they do not exist.<a name="line.1913"></a>
-<span class="sourceLineNo">1914</span>     *<a name="line.1914"></a>
-<span class="sourceLineNo">1915</span>     * @param file  the file to write<a name="line.1915"></a>
-<span class="sourceLineNo">1916</span>     * @param data  the content to write to the file<a name="line.1916"></a>
-<span class="sourceLineNo">1917</span>     * @param encoding  the encoding to use, {@code null} means platform default<a name="line.1917"></a>
-<span class="sourceLineNo">1918</span>     * @throws IOException in case of an I/O error<a name="line.1918"></a>
-<span class="sourceLineNo">1919</span>     * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM<a name="line.1919"></a>
-<span class="sourceLineNo">1920</span>     * @since 2.4<a name="line.1920"></a>
-<span class="sourceLineNo">1921</span>     */<a name="line.1921"></a>
-<span class="sourceLineNo">1922</span>    public static void writeStringToFile(final File file, final String data, final Charset encoding) throws IOException {<a name="line.1922"></a>
-<span class="sourceLineNo">1923</span>        writeStringToFile(file, data, encoding, false);<a name="line.1923"></a>
-<span class="sourceLineNo">1924</span>    }<a name="line.1924"></a>
-<span class="sourceLineNo">1925</span><a name="line.1925"></a>
-<span class="sourceLineNo">1926</span>    /**<a name="line.1926"></a>
-<span class="sourceLineNo">1927</span>     * Writes a String to a file creating the file if it does not exist.<a name="line.1927"></a>
+<span class="sourceLineNo">1912</span>     * @param file  the file to write<a name="line.1912"></a>
+<span class="sourceLineNo">1913</span>     * @param data  the content to write to the file<a name="line.1913"></a>
+<span class="sourceLineNo">1914</span>     * @param encoding  the encoding to use, {@code null} means platform default<a name="line.1914"></a>
+<span class="sourceLineNo">1915</span>     * @throws IOException in case of an I/O error<a name="line.1915"></a>
+<span class="sourceLineNo">1916</span>     * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM<a name="line.1916"></a>
+<span class="sourceLineNo">1917</span>     * @since 2.4<a name="line.1917"></a>
+<span class="sourceLineNo">1918</span>     */<a name="line.1918"></a>
+<span class="sourceLineNo">1919</span>    public static void writeStringToFile(final File file, final String data, final Charset encoding) throws IOException {<a name="line.1919"></a>
+<span class="sourceLineNo">1920</span>        writeStringToFile(file, data, encoding, false);<a name="line.1920"></a>
+<span class="sourceLineNo">1921</span>    }<a name="line.1921"></a>
+<span class="sourceLineNo">1922</span><a name="line.1922"></a>
+<span class="sourceLineNo">1923</span>    /**<a name="line.1923"></a>
+<span class="sourceLineNo">1924</span>     * Writes a String to a file creating the file if it does not exist.<a name="line.1924"></a>
+<span class="sourceLineNo">1925</span>     *<a name="line.1925"></a>
+<span class="sourceLineNo">1926</span>     * NOTE: As from v1.3, the parent directories of the file will be created<a name="line.1926"></a>
+<span class="sourceLineNo">1927</span>     * if they do not exist.<a name="line.1927"></a>
 <span class="sourceLineNo">1928</span>     *<a name="line.1928"></a>
-<span class="sourceLineNo">1929</span>     * NOTE: As from v1.3, the parent directories of the file will be created<a name="line.1929"></a>
-<span class="sourceLineNo">1930</span>     * if they do not exist.<a name="line.1930"></a>
-<span class="sourceLineNo">1931</span>     *<a name="line.1931"></a>
-<span class="sourceLineNo">1932</span>     * @param file  the file to write<a name="line.1932"></a>
-<span class="sourceLineNo">1933</span>     * @param data  the content to write to the file<a name="line.1933"></a>
-<span class="sourceLineNo">1934</span>     * @param encoding  the encoding to use, {@code null} means platform default<a name="line.1934"></a>
-<span class="sourceLineNo">1935</span>     * @throws IOException in case of an I/O error<a name="line.1935"></a>
-<span class="sourceLineNo">1936</span>     * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM<a name="line.1936"></a>
-<span class="sourceLineNo">1937</span>     */<a name="line.1937"></a>
-<span class="sourceLineNo">1938</span>    public static void writeStringToFile(final File file, final String data, final String encoding) throws IOException {<a name="line.1938"></a>
-<span class="sourceLineNo">1939</span>        writeStringToFile(file, data, encoding, false);<a name="line.1939"></a>
-<span class="sourceLineNo">1940</span>    }<a name="line.1940"></a>
-<span class="sourceLineNo">1941</span><a name="line.1941"></a>
-<span class="sourceLineNo">1942</span>    /**<a name="line.1942"></a>
-<span class="sourceLineNo">1943</span>     * Writes a String to a file creating the file if it does not exist.<a name="line.1943"></a>
-<span class="sourceLineNo">1944</span>     *<a name="line.1944"></a>
-<span class="sourceLineNo">1945</span>     * @param file  the file to write<a name="line.1945"></a>
-<span class="sourceLineNo">1946</span>     * @param data  the content to write to the file<a name="line.1946"></a>
-<span class="sourceLineNo">1947</span>     * @param encoding  the encoding to use, {@code null} means platform default<a name="line.1947"></a>
-<span class="sourceLineNo">1948</span>     * @param append if {@code true}, then the String will be added to the<a name="line.1948"></a>
-<span class="sourceLineNo">1949</span>     * end of the file rather than overwriting<a name="line.1949"></a>
-<span class="sourceLineNo">1950</span>     * @throws IOException in case of an I/O error<a name="line.1950"></a>
-<span class="sourceLineNo">1951</span>     * @since 2.3<a name="line.1951"></a>
-<span class="sourceLineNo">1952</span>     */<a name="line.1952"></a>
-<span class="sourceLineNo">1953</span>    public static void writeStringToFile(final File file, final String data, final Charset encoding, final boolean append) throws IOException {<a name="line.1953"></a>
-<span class="sourceLineNo">1954</span>        OutputStream out = null;<a name="line.1954"></a>
-<span class="sourceLineNo">1955</span>        try {<a name="line.1955"></a>
-<span class="sourceLineNo">1956</span>            out = openOutputStream(file, append);<a name="line.1956"></a>
-<span class="sourceLineNo">1957</span>            IOUtils.write(data, out, encoding);<a name="line.1957"></a>
-<span class="sourceLineNo">1958</span>            out.close(); // don't swallow close Exception if copy completes normally<a name="line.1958"></a>
-<span class="sourceLineNo">1959</span>        } finally {<a name="line.1959"></a>
-<span class="sourceLineNo">1960</span>            IOUtils.closeQuietly(out);<a name="line.1960"></a>
-<span class="sourceLineNo">1961</span>        }<a name="line.1961"></a>
-<span class="sourceLineNo">1962</span>    }<a name="line.1962"></a>

[... 2168 lines stripped ...]


Mime
View raw message