Index: 3rdParty_sources/commons-io/org/apache/commons/io/ByteOrderMark.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/ByteOrderMark.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/ByteOrderMark.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/ByteOrderMark.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -19,25 +19,40 @@ import java.io.Serializable; /** - * Byte Order Mark (BOM) representation - - * see {@link org.apache.commons.io.input.BOMInputStream}. - * + * Byte Order Mark (BOM) representation - see {@link org.apache.commons.io.input.BOMInputStream}. + * * @see org.apache.commons.io.input.BOMInputStream - * @see Wikipedia - Byte Order Mark + * @see Wikipedia: Byte Order Mark + * @see W3C: Autodetection of Character Encodings + * (Non-Normative) * @version $Id$ - * @since Commons IO 2.0 + * @since 2.0 */ public class ByteOrderMark implements Serializable { private static final long serialVersionUID = 1L; /** UTF-8 BOM */ public static final ByteOrderMark UTF_8 = new ByteOrderMark("UTF-8", 0xEF, 0xBB, 0xBF); - /** UTF-16BE BOM (Big Endian) */ + + /** UTF-16BE BOM (Big-Endian) */ public static final ByteOrderMark UTF_16BE = new ByteOrderMark("UTF-16BE", 0xFE, 0xFF); - /** UTF-16LE BOM (Little Endian) */ + + /** UTF-16LE BOM (Little-Endian) */ public static final ByteOrderMark UTF_16LE = new ByteOrderMark("UTF-16LE", 0xFF, 0xFE); + /** + * UTF-32BE BOM (Big-Endian) + * @since 2.2 + */ + public static final ByteOrderMark UTF_32BE = new ByteOrderMark("UTF-32BE", 0x00, 0x00, 0xFE, 0xFF); + + /** + * UTF-32LE BOM (Little-Endian) + * @since 2.2 + */ + public static final ByteOrderMark UTF_32LE = new ByteOrderMark("UTF-32LE", 0xFF, 0xFE, 0x00, 0x00); + private final String charsetName; private final int[] bytes; Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/commons-io/org/apache/commons/io/Charsets.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/commons-io/org/apache/commons/io/CopyUtils.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/CopyUtils.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/CopyUtils.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/CopyUtils.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -102,9 +102,6 @@ *

* Origin of code: Excalibur. * - * @author Peter Donald - * @author Jeff Turner - * @author Matthew Hawthorne * @version $Id$ * @deprecated Use IOUtils. Will be removed in 2.0. * Methods renamed to IOUtils.write() or IOUtils.copy(). Index: 3rdParty_sources/commons-io/org/apache/commons/io/DirectoryWalker.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/DirectoryWalker.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/DirectoryWalker.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/DirectoryWalker.java 1 Aug 2014 09:13:51 -0000 1.1.2.1 @@ -245,8 +245,8 @@ * } * * - * @since Commons IO 1.3 - * @version $Revision$ + * @since 1.3 + * @version $Id$ */ public abstract class DirectoryWalker { @@ -271,7 +271,7 @@ *

* The filter controls which files and directories will be navigated to as * part of the walk. The {@link FileFilterUtils} class is useful for combining - * various filters together. A null filter means that no + * various filters together. A {@code null} filter means that no * filtering should occur and all files and directories will be visited. * * @param filter the filter to apply, null means visit all files @@ -290,7 +290,7 @@ * The filters control which files and directories will be navigated to as part * of the walk. This constructor uses {@link FileFilterUtils#makeDirectoryOnly(IOFileFilter)} * and {@link FileFilterUtils#makeFileOnly(IOFileFilter)} internally to combine the filters. - * A null filter means that no filtering should occur. + * A {@code null} filter means that no filtering should occur. * * @param directoryFilter the filter to apply to directories, null means visit all directories * @param fileFilter the filter to apply to files, null means visit all files @@ -301,8 +301,8 @@ if (directoryFilter == null && fileFilter == null) { this.filter = null; } else { - directoryFilter = (directoryFilter != null ? directoryFilter : TrueFileFilter.TRUE); - fileFilter = (fileFilter != null ? fileFilter : TrueFileFilter.TRUE); + directoryFilter = directoryFilter != null ? directoryFilter : TrueFileFilter.TRUE; + fileFilter = fileFilter != null ? fileFilter : TrueFileFilter.TRUE; directoryFilter = FileFilterUtils.makeDirectoryOnly(directoryFilter); fileFilter = FileFilterUtils.makeFileOnly(fileFilter); this.filter = FileFilterUtils.or(directoryFilter, fileFilter); @@ -354,7 +354,7 @@ int childDepth = depth + 1; if (depthLimit < 0 || childDepth <= depthLimit) { checkIfCancelled(directory, depth, results); - File[] childFiles = (filter == null ? directory.listFiles() : directory.listFiles(filter)); + File[] childFiles = filter == null ? directory.listFiles() : directory.listFiles(filter); childFiles = filterDirectoryContents(directory, depth, childFiles); if (childFiles == null) { handleRestricted(directory, childDepth, results); @@ -514,7 +514,7 @@ * @param files the files (possibly filtered) in the directory * @return the filtered list of files * @throws IOException if an I/O Error occurs - * @since Commons IO 2.0 + * @since 2.0 */ protected File[] filterDirectoryContents(File directory, int depth, File[] files) throws IOException { return files; Index: 3rdParty_sources/commons-io/org/apache/commons/io/EndianUtils.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/EndianUtils.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/EndianUtils.java 1 Oct 2012 13:03:03 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/EndianUtils.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -33,7 +33,6 @@ *

* Origin of code: Excalibur * - * @author Peter Donald * @version $Id$ * @see org.apache.commons.io.input.SwappedDataInputStream */ Index: 3rdParty_sources/commons-io/org/apache/commons/io/FileCleaner.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/FileCleaner.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/FileCleaner.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/FileCleaner.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -32,8 +32,6 @@ * {@link #exitWhenFinished}, typically in * {@link javax.servlet.ServletContextListener#contextDestroyed} or similar. * - * @author Noel Bergman - * @author Martin Cooper * @version $Id$ * @deprecated Use {@link FileCleaningTracker} */ Index: 3rdParty_sources/commons-io/org/apache/commons/io/FileCleaningTracker.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/FileCleaningTracker.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/FileCleaningTracker.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/FileCleaningTracker.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -39,8 +39,6 @@ * {@link #exitWhenFinished}, typically in * {@link javax.servlet.ServletContextListener#contextDestroyed} or similar. * - * @author Noel Bergman - * @author Martin Cooper * @version $Id$ */ public class FileCleaningTracker { @@ -160,7 +158,7 @@ * Return the file paths that failed to delete. * * @return the file paths that failed to delete - * @since Commons IO 2.0 + * @since 2.0 */ public List getDeleteFailures() { return deleteFailures; @@ -258,7 +256,7 @@ Tracker(String path, FileDeleteStrategy deleteStrategy, Object marker, ReferenceQueue queue) { super(marker, queue); this.path = path; - this.deleteStrategy = (deleteStrategy == null ? FileDeleteStrategy.NORMAL : deleteStrategy); + this.deleteStrategy = deleteStrategy == null ? FileDeleteStrategy.NORMAL : deleteStrategy; } /** @@ -273,8 +271,8 @@ /** * Deletes the file associated with this tracker instance. * - * @return true if the file was deleted successfully; - * false otherwise. + * @return {@code true} if the file was deleted successfully; + * {@code false} otherwise. */ public boolean delete() { return deleteStrategy.deleteQuietly(new File(path)); Index: 3rdParty_sources/commons-io/org/apache/commons/io/FileDeleteStrategy.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/FileDeleteStrategy.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/FileDeleteStrategy.java 1 Oct 2012 13:03:03 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/FileDeleteStrategy.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -28,9 +28,8 @@ *

* This class captures the strategy to use and is designed for user subclassing. * - * @author Stephen Colebourne * @version $Id$ - * @since Commons IO 1.3 + * @since 1.3 */ public class FileDeleteStrategy { @@ -144,7 +143,7 @@ * if the file exists. * * @param fileToDelete the file to delete, not null - * @return Always returns true + * @return Always returns {@code true} * @throws NullPointerException if the file is null * @throws IOException if an error occurs during file deletion */ Index: 3rdParty_sources/commons-io/org/apache/commons/io/FileExistsException.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/FileExistsException.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/FileExistsException.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/FileExistsException.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -23,7 +23,7 @@ * Indicates that a file already exists. * * @version $Id$ - * @since Commons IO 2.0 + * @since 2.0 */ public class FileExistsException extends IOException { Index: 3rdParty_sources/commons-io/org/apache/commons/io/FileSystemUtils.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/FileSystemUtils.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/FileSystemUtils.java 1 Oct 2012 13:03:03 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/FileSystemUtils.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -39,14 +39,8 @@ *

  • Get the free space on a drive * * - * @author Frank W. Zammetti - * @author Stephen Colebourne - * @author Thomas Ledoux - * @author James Urie - * @author Magnus Grimsell - * @author Thomas Ledoux * @version $Id$ - * @since Commons IO 1.1 + * @since 1.1 */ public class FileSystemUtils { @@ -139,7 +133,7 @@ * @throws IllegalArgumentException if the path is invalid * @throws IllegalStateException if an error occurred in initialisation * @throws IOException if an error occurs when finding the free space - * @since Commons IO 1.1, enhanced OS support in 1.2 and 1.3 + * @since 1.1, enhanced OS support in 1.2 and 1.3 * @deprecated Use freeSpaceKb(String) * Deprecated from 1.3, may be removed in 2.0 */ @@ -171,7 +165,7 @@ * @throws IllegalArgumentException if the path is invalid * @throws IllegalStateException if an error occurred in initialisation * @throws IOException if an error occurs when finding the free space - * @since Commons IO 1.2, enhanced OS support in 1.3 + * @since 1.2, enhanced OS support in 1.3 */ public static long freeSpaceKb(String path) throws IOException { return freeSpaceKb(path, -1); @@ -200,7 +194,7 @@ * @throws IllegalArgumentException if the path is invalid * @throws IllegalStateException if an error occurred in initialisation * @throws IOException if an error occurs when finding the free space - * @since Commons IO 2.0 + * @since 2.0 */ public static long freeSpaceKb(String path, long timeout) throws IOException { return INSTANCE.freeSpaceOS(path, OS, true, timeout); @@ -216,7 +210,7 @@ * @return the amount of free drive space on the drive or volume in kilobytes * @throws IllegalStateException if an error occurred in initialisation * @throws IOException if an error occurs when finding the free space - * @since Commons IO 2.0 + * @since 2.0 */ public static long freeSpaceKb() throws IOException { return freeSpaceKb(-1); @@ -234,7 +228,7 @@ * @return the amount of free drive space on the drive or volume in kilobytes * @throws IllegalStateException if an error occurred in initialisation * @throws IOException if an error occurs when finding the free space - * @since Commons IO 2.0 + * @since 2.0 */ public static long freeSpaceKb(long timeout) throws IOException { return freeSpaceKb(new File(".").getAbsolutePath(), timeout); @@ -267,7 +261,7 @@ } switch (os) { case WINDOWS: - return (kb ? freeSpaceWindows(path, timeout) / FileUtils.ONE_KB : freeSpaceWindows(path, timeout)); + return kb ? freeSpaceWindows(path, timeout) / FileUtils.ONE_KB : freeSpaceWindows(path, timeout); case UNIX: return freeSpaceUnix(path, kb, false, timeout); case POSIX_UNIX: @@ -396,7 +390,7 @@ flags += "P"; } String[] cmdAttribs = - (flags.length() > 1 ? new String[] {DF, flags, path} : new String[] {DF, path}); + flags.length() > 1 ? new String[] {DF, flags, path} : new String[] {DF, path}; // perform the command, asking for up to 3 lines (header, interesting, overflow) List lines = performCommand(cmdAttribs, 3, timeout); @@ -507,7 +501,7 @@ "Command line returned OS error code '" + proc.exitValue() + "' for command " + Arrays.asList(cmdAttribs)); } - if (lines.size() == 0) { + if (lines.isEmpty()) { // unknown problem, throw exception throw new IOException( "Command line did not return any info " + Index: 3rdParty_sources/commons-io/org/apache/commons/io/FileUtils.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/FileUtils.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/FileUtils.java 1 Oct 2012 13:03:03 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/FileUtils.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -16,20 +16,25 @@ */ package org.apache.commons.io; +import java.io.BufferedOutputStream; import java.io.File; import java.io.FileFilter; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.io.OutputStream; +import java.io.Reader; +import java.io.UnsupportedEncodingException; import java.math.BigInteger; import java.net.URL; import java.net.URLConnection; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.nio.charset.Charset; +import java.nio.charset.UnsupportedCharsetException; import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -66,19 +71,6 @@ *

    * Origin of code: Excalibur, Alexandria, Commons-Utils * - * @author Kevin A. Burton - * @author Scott Sanders - * @author Daniel Rall - * @author Christoph.Reck - * @author Peter Donald - * @author Jeff Turner - * @author Matthew Hawthorne - * @author Jeremias Maerki - * @author Stephen Colebourne - * @author Ian Springer - * @author Chris Eldredge - * @author Jim Harrington - * @author Sandy McArthur * @version $Id$ */ public class FileUtils { @@ -96,11 +88,25 @@ public static final long ONE_KB = 1024; /** + * The number of bytes in a kilobyte. + * + * @since 2.4 + */ + public static final BigInteger ONE_KB_BI = BigInteger.valueOf(ONE_KB); + + /** * The number of bytes in a megabyte. */ public static final long ONE_MB = ONE_KB * ONE_KB; /** + * The number of bytes in a megabyte. + * + * @since 2.4 + */ + public static final BigInteger ONE_MB_BI = ONE_KB_BI.multiply(ONE_KB_BI); + + /** * The file copy buffer size (30 MB) */ private static final long FILE_COPY_BUFFER_SIZE = ONE_MB * 30; @@ -111,29 +117,57 @@ public static final long ONE_GB = ONE_KB * ONE_MB; /** + * The number of bytes in a gigabyte. + * + * @since 2.4 + */ + public static final BigInteger ONE_GB_BI = ONE_KB_BI.multiply(ONE_MB_BI); + + /** * The number of bytes in a terabyte. */ public static final long ONE_TB = ONE_KB * ONE_GB; /** + * The number of bytes in a terabyte. + * + * @since 2.4 + */ + public static final BigInteger ONE_TB_BI = ONE_KB_BI.multiply(ONE_GB_BI); + + /** * The number of bytes in a petabyte. */ public static final long ONE_PB = ONE_KB * ONE_TB; /** + * The number of bytes in a petabyte. + * + * @since 2.4 + */ + public static final BigInteger ONE_PB_BI = ONE_KB_BI.multiply(ONE_TB_BI); + + /** * The number of bytes in an exabyte. */ public static final long ONE_EB = ONE_KB * ONE_PB; /** + * The number of bytes in an exabyte. + * + * @since 2.4 + */ + public static final BigInteger ONE_EB_BI = ONE_KB_BI.multiply(ONE_PB_BI); + + /** * The number of bytes in a zettabyte. */ public static final BigInteger ONE_ZB = BigInteger.valueOf(ONE_KB).multiply(BigInteger.valueOf(ONE_EB)); /** * The number of bytes in a yottabyte. */ - public static final BigInteger ONE_YB = ONE_ZB.multiply(BigInteger.valueOf(ONE_EB)); + public static final BigInteger ONE_YB = ONE_KB_BI.multiply(ONE_ZB); /** * An empty array of type File. @@ -152,7 +186,7 @@ * @param directory the parent directory * @param names the name elements * @return the file - * @since Commons IO 2.1 + * @since 2.1 */ public static File getFile(File directory, String... names) { if (directory == null) { @@ -173,7 +207,7 @@ * * @param names the name elements * @return the file - * @since Commons IO 2.1 + * @since 2.1 */ public static File getFile(String... names) { if (names == null) { @@ -195,7 +229,7 @@ * * @return the path to the system temporary directory. * - * @since Commons IO 2.0 + * @since 2.0 */ public static String getTempDirectoryPath() { return System.getProperty("java.io.tmpdir"); @@ -206,7 +240,7 @@ * * @return the system temporary directory. * - * @since Commons IO 2.0 + * @since 2.0 */ public static File getTempDirectory() { return new File(getTempDirectoryPath()); @@ -217,7 +251,7 @@ * * @return the path to the user's home directory. * - * @since Commons IO 2.0 + * @since 2.0 */ public static String getUserDirectoryPath() { return System.getProperty("user.home"); @@ -228,7 +262,7 @@ * * @return the user's home directory. * - * @since Commons IO 2.0 + * @since 2.0 */ public static File getUserDirectory() { return new File(getUserDirectoryPath()); @@ -246,12 +280,12 @@ * An exception is thrown if the file object exists but is a directory. * An exception is thrown if the file exists but cannot be read. * - * @param file the file to open for input, must not be null + * @param file the file to open for input, must not be {@code null} * @return a new {@link FileInputStream} for the specified file * @throws FileNotFoundException if the file does not exist * @throws IOException if the file object is a directory * @throws IOException if the file cannot be read - * @since Commons IO 1.3 + * @since 1.3 */ public static FileInputStream openInputStream(File file) throws IOException { if (file.exists()) { @@ -281,12 +315,12 @@ * An exception is thrown if the file exists but cannot be written to. * An exception is thrown if the parent directory cannot be created. * - * @param file the file to open for output, must not be null + * @param file the file to open for output, must not be {@code null} * @return a new {@link FileOutputStream} for the specified file * @throws IOException if the file object is a directory * @throws IOException if the file cannot be written to * @throws IOException if a parent directory needs creating but that fails - * @since Commons IO 1.3 + * @since 1.3 */ public static FileOutputStream openOutputStream(File file) throws IOException { return openOutputStream(file, false); @@ -305,14 +339,14 @@ * An exception is thrown if the file exists but cannot be written to. * An exception is thrown if the parent directory cannot be created. * - * @param file the file to open for output, must not be null - * @param append if true, then bytes will be added to the + * @param file the file to open for output, must not be {@code null} + * @param append if {@code true}, then bytes will be added to the * end of the file rather than overwriting * @return a new {@link FileOutputStream} for the specified file * @throws IOException if the file object is a directory * @throws IOException if the file cannot be written to * @throws IOException if a parent directory needs creating but that fails - * @since Commons IO 2.1 + * @since 2.1 */ public static FileOutputStream openOutputStream(File file, boolean append) throws IOException { if (file.exists()) { @@ -335,40 +369,63 @@ //----------------------------------------------------------------------- /** - * Returns a human-readable version of the file size, where the input - * represents a specific number of bytes. - * - * If the size is over 1GB, the size is returned as the number of whole GB, - * i.e. the size is rounded down to the nearest GB boundary. - * + * Returns a human-readable version of the file size, where the input represents a specific number of bytes. + *

    + * If the size is over 1GB, the size is returned as the number of whole GB, i.e. the size is rounded down to the + * nearest GB boundary. + *

    + *

    * Similarly for the 1MB and 1KB boundaries. - * - * @param size the number of bytes - * @return a human-readable display value (includes units - GB, MB, KB or bytes) + *

    + * + * @param size + * the number of bytes + * @return a human-readable display value (includes units - EB, PB, TB, GB, MB, KB or bytes) + * @see IO-226 - should the rounding be changed? + * @since 2.4 */ // See https://issues.apache.org/jira/browse/IO-226 - should the rounding be changed? - public static String byteCountToDisplaySize(long size) { + public static String byteCountToDisplaySize(BigInteger size) { String displaySize; -// if (size / ONE_EB > 0) { -// displaySize = String.valueOf(size / ONE_EB) + " EB"; -// } else if (size / ONE_PB > 0) { -// displaySize = String.valueOf(size / ONE_PB) + " PB"; -// } else if (size / ONE_TB > 0) { -// displaySize = String.valueOf(size / ONE_TB) + " TB"; -// } else - if (size / ONE_GB > 0) { - displaySize = String.valueOf(size / ONE_GB) + " GB"; - } else if (size / ONE_MB > 0) { - displaySize = String.valueOf(size / ONE_MB) + " MB"; - } else if (size / ONE_KB > 0) { - displaySize = String.valueOf(size / ONE_KB) + " KB"; + if (size.divide(ONE_EB_BI).compareTo(BigInteger.ZERO) > 0) { + displaySize = String.valueOf(size.divide(ONE_EB_BI)) + " EB"; + } else if (size.divide(ONE_PB_BI).compareTo(BigInteger.ZERO) > 0) { + displaySize = String.valueOf(size.divide(ONE_PB_BI)) + " PB"; + } else if (size.divide(ONE_TB_BI).compareTo(BigInteger.ZERO) > 0) { + displaySize = String.valueOf(size.divide(ONE_TB_BI)) + " TB"; + } else if (size.divide(ONE_GB_BI).compareTo(BigInteger.ZERO) > 0) { + displaySize = String.valueOf(size.divide(ONE_GB_BI)) + " GB"; + } else if (size.divide(ONE_MB_BI).compareTo(BigInteger.ZERO) > 0) { + displaySize = String.valueOf(size.divide(ONE_MB_BI)) + " MB"; + } else if (size.divide(ONE_KB_BI).compareTo(BigInteger.ZERO) > 0) { + displaySize = String.valueOf(size.divide(ONE_KB_BI)) + " KB"; } else { displaySize = String.valueOf(size) + " bytes"; } return displaySize; } + /** + * Returns a human-readable version of the file size, where the input represents a specific number of bytes. + *

    + * If the size is over 1GB, the size is returned as the number of whole GB, i.e. the size is rounded down to the + * nearest GB boundary. + *

    + *

    + * Similarly for the 1MB and 1KB boundaries. + *

    + * + * @param size + * the number of bytes + * @return a human-readable display value (includes units - EB, PB, TB, GB, MB, KB or bytes) + * @see IO-226 - should the rounding be changed? + */ + // See https://issues.apache.org/jira/browse/IO-226 - should the rounding be changed? + public static String byteCountToDisplaySize(long size) { + return byteCountToDisplaySize(BigInteger.valueOf(size)); + } + //----------------------------------------------------------------------- /** * Implements the same behaviour as the "touch" utility on Unix. It creates @@ -414,14 +471,19 @@ * @param files the collection of files found. * @param directory the directory to search in. * @param filter the filter to apply to files and directories. + * @param includeSubDirectories indicates if will include the subdirectories themselves */ private static void innerListFiles(Collection files, File directory, - IOFileFilter filter) { + IOFileFilter filter, boolean includeSubDirectories) { File[] found = directory.listFiles((FileFilter) filter); + if (found != null) { for (File file : found) { if (file.isDirectory()) { - innerListFiles(files, file, filter); + if (includeSubDirectories) { + files.add(file); + } + innerListFiles(files, file, filter, includeSubDirectories); } else { files.add(file); } @@ -448,39 +510,98 @@ * @param directory the directory to search in * @param fileFilter filter to apply when finding files. * @param dirFilter optional filter to apply when finding subdirectories. - * If this parameter is null, subdirectories will not be included in the + * If this parameter is {@code null}, subdirectories will not be included in the * search. Use TrueFileFilter.INSTANCE to match all directories. * @return an collection of java.io.File with the matching files * @see org.apache.commons.io.filefilter.FileFilterUtils * @see org.apache.commons.io.filefilter.NameFileFilter */ public static Collection listFiles( File directory, IOFileFilter fileFilter, IOFileFilter dirFilter) { + validateListFilesParameters(directory, fileFilter); + + IOFileFilter effFileFilter = setUpEffectiveFileFilter(fileFilter); + IOFileFilter effDirFilter = setUpEffectiveDirFilter(dirFilter); + + //Find files + Collection files = new java.util.LinkedList(); + innerListFiles(files, directory, + FileFilterUtils.or(effFileFilter, effDirFilter), false); + return files; + } + + /** + * Validates the given arguments. + *
      + *
    • Throws {@link IllegalArgumentException} if {@code directory} is not a directory
    • + *
    • Throws {@link NullPointerException} if {@code fileFilter} is null
    • + *
    + * + * @param directory The File to test + * @param fileFilter The IOFileFilter to test + */ + private static void validateListFilesParameters(File directory, IOFileFilter fileFilter) { if (!directory.isDirectory()) { - throw new IllegalArgumentException( - "Parameter 'directory' is not a directory"); + throw new IllegalArgumentException("Parameter 'directory' is not a directory"); } if (fileFilter == null) { throw new NullPointerException("Parameter 'fileFilter' is null"); } + } - //Setup effective file filter - IOFileFilter effFileFilter = FileFilterUtils.and(fileFilter, - FileFilterUtils.notFileFilter(DirectoryFileFilter.INSTANCE)); + /** + * Returns a filter that accepts files in addition to the {@link File} objects accepted by the given filter. + * + * @param fileFilter a base filter to add to + * @return a filter that accepts files + */ + private static IOFileFilter setUpEffectiveFileFilter(IOFileFilter fileFilter) { + return FileFilterUtils.and(fileFilter, FileFilterUtils.notFileFilter(DirectoryFileFilter.INSTANCE)); + } - //Setup effective directory filter - IOFileFilter effDirFilter; - if (dirFilter == null) { - effDirFilter = FalseFileFilter.INSTANCE; - } else { - effDirFilter = FileFilterUtils.and(dirFilter, + /** + * Returns a filter that accepts directories in addition to the {@link File} objects accepted by the given filter. + * + * @param dirFilter a base filter to add to + * @return a filter that accepts directories + */ + private static IOFileFilter setUpEffectiveDirFilter(IOFileFilter dirFilter) { + return dirFilter == null ? FalseFileFilter.INSTANCE : FileFilterUtils.and(dirFilter, DirectoryFileFilter.INSTANCE); - } + } + /** + * Finds files within a given directory (and optionally its + * subdirectories). All files found are filtered by an IOFileFilter. + *

    + * The resulting collection includes the subdirectories themselves. + *

    + * @see org.apache.commons.io.FileUtils#listFiles + * + * @param directory the directory to search in + * @param fileFilter filter to apply when finding files. + * @param dirFilter optional filter to apply when finding subdirectories. + * If this parameter is {@code null}, subdirectories will not be included in the + * search. Use TrueFileFilter.INSTANCE to match all directories. + * @return an collection of java.io.File with the matching files + * @see org.apache.commons.io.filefilter.FileFilterUtils + * @see org.apache.commons.io.filefilter.NameFileFilter + * @since 2.2 + */ + public static Collection listFilesAndDirs( + File directory, IOFileFilter fileFilter, IOFileFilter dirFilter) { + validateListFilesParameters(directory, fileFilter); + + IOFileFilter effFileFilter = setUpEffectiveFileFilter(fileFilter); + IOFileFilter effDirFilter = setUpEffectiveDirFilter(dirFilter); + //Find files Collection files = new java.util.LinkedList(); + if (directory.isDirectory()) { + files.add(directory); + } innerListFiles(files, directory, - FileFilterUtils.or(effFileFilter, effDirFilter)); + FileFilterUtils.or(effFileFilter, effDirFilter), true); return files; } @@ -495,18 +616,42 @@ * @param directory the directory to search in * @param fileFilter filter to apply when finding files. * @param dirFilter optional filter to apply when finding subdirectories. - * If this parameter is null, subdirectories will not be included in the + * If this parameter is {@code null}, subdirectories will not be included in the * search. Use TrueFileFilter.INSTANCE to match all directories. * @return an iterator of java.io.File for the matching files * @see org.apache.commons.io.filefilter.FileFilterUtils * @see org.apache.commons.io.filefilter.NameFileFilter - * @since Commons IO 1.2 + * @since 1.2 */ public static Iterator iterateFiles( File directory, IOFileFilter fileFilter, IOFileFilter dirFilter) { return listFiles(directory, fileFilter, dirFilter).iterator(); } + /** + * Allows iteration over the files in given directory (and optionally + * its subdirectories). + *

    + * All files found are filtered by an IOFileFilter. This method is + * based on {@link #listFilesAndDirs(File, IOFileFilter, IOFileFilter)}, + * which supports Iterable ('foreach' loop). + *

    + * The resulting iterator includes the subdirectories themselves. + * + * @param directory the directory to search in + * @param fileFilter filter to apply when finding files. + * @param dirFilter optional filter to apply when finding subdirectories. + * If this parameter is {@code null}, subdirectories will not be included in the + * search. Use TrueFileFilter.INSTANCE to match all directories. + * @return an iterator of java.io.File for the matching files + * @see org.apache.commons.io.filefilter.FileFilterUtils + * @see org.apache.commons.io.filefilter.NameFileFilter + * @since 2.2 + */ + public static Iterator iterateFilesAndDirs(File directory, IOFileFilter fileFilter, IOFileFilter dirFilter) { + return listFilesAndDirs(directory, fileFilter, dirFilter).iterator(); + } + //----------------------------------------------------------------------- /** * Converts an array of file extensions to suffixes for use @@ -530,7 +675,7 @@ * * @param directory the directory to search in * @param extensions an array of extensions, ex. {"java","xml"}. If this - * parameter is null, all files are returned. + * parameter is {@code null}, all files are returned. * @param recursive if true all subdirectories are searched as well * @return an collection of java.io.File with the matching files */ @@ -544,7 +689,7 @@ filter = new SuffixFileFilter(suffixes); } return listFiles(directory, filter, - (recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE)); + recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE); } /** @@ -555,10 +700,10 @@ * * @param directory the directory to search in * @param extensions an array of extensions, ex. {"java","xml"}. If this - * parameter is null, all files are returned. + * parameter is {@code null}, all files are returned. * @param recursive if true all subdirectories are searched as well * @return an iterator of java.io.File with the matching files - * @since Commons IO 1.2 + * @since 1.2 */ public static Iterator iterateFiles( File directory, String[] extensions, boolean recursive) { @@ -622,6 +767,63 @@ //----------------------------------------------------------------------- /** + * Compares the contents of two files to determine if they are equal or not. + *

    + * This method checks to see if the two files point to the same file, + * before resorting to line-by-line comparison of the contents. + *

    + * + * @param file1 the first file + * @param file2 the second file + * @param charsetName the character encoding to be used. + * May be null, in which case the platform default is used + * @return true if the content of the files are equal or neither exists, + * false otherwise + * @throws IOException in case of an I/O error + * @since 2.2 + * @see IOUtils#contentEqualsIgnoreEOL(Reader, Reader) + */ + public static boolean contentEqualsIgnoreEOL(File file1, File file2, String charsetName) throws IOException { + boolean file1Exists = file1.exists(); + if (file1Exists != file2.exists()) { + return false; + } + + if (!file1Exists) { + // two not existing files are equal + return true; + } + + if (file1.isDirectory() || file2.isDirectory()) { + // don't want to compare directory contents + throw new IOException("Can't compare directories, only files"); + } + + if (file1.getCanonicalFile().equals(file2.getCanonicalFile())) { + // same file + return true; + } + + Reader input1 = null; + Reader input2 = null; + try { + if (charsetName == null) { + input1 = new InputStreamReader(new FileInputStream(file1)); + input2 = new InputStreamReader(new FileInputStream(file2)); + } else { + input1 = new InputStreamReader(new FileInputStream(file1), charsetName); + input2 = new InputStreamReader(new FileInputStream(file2), charsetName); + } + return IOUtils.contentEqualsIgnoreEOL(input1, input2); + + } finally { + IOUtils.closeQuietly(input1); + IOUtils.closeQuietly(input2); + } + } + + //----------------------------------------------------------------------- + /** * Convert from a URL to a File. *

    * From version 1.1 this method will decode the URL. @@ -631,8 +833,8 @@ * Additionally, malformed percent-encoded octets are handled leniently by * passing them through literally. * - * @param url the file URL to convert, null returns null - * @return the equivalent File object, or null + * @param url the file URL to convert, {@code null} returns {@code null} + * @return the equivalent File object, or {@code null} * if the URL's protocol is not file */ public static File toFile(URL url) { @@ -655,9 +857,9 @@ * result string. Except for rare edge cases, this will make unencoded URLs * pass through unaltered. * - * @param url The URL to decode, may be null. - * @return The decoded URL or null if the input was - * null. + * @param url The URL to decode, may be {@code null}. + * @return The decoded URL or {@code null} if the input was + * {@code null}. */ static String decodeUrl(String url) { String decoded = url; @@ -696,20 +898,20 @@ * Converts each of an array of URL to a File. *

    * Returns an array of the same size as the input. - * If the input is null, an empty array is returned. - * If the input contains null, the output array contains null at the same + * If the input is {@code null}, an empty array is returned. + * If the input contains {@code null}, the output array contains {@code null} at the same * index. *

    * This method will decode the URL. * Syntax such as file:///my%20docs/file.txt will be * correctly decoded to /my docs/file.txt. * - * @param urls the file URLs to convert, null returns empty array - * @return a non-null array of Files matching the input, with a null item - * if there was a null at that index in the input array + * @param urls the file URLs to convert, {@code null} returns empty array + * @return a non-{@code null} array of Files matching the input, with a {@code null} item + * if there was a {@code null} at that index in the input array * @throws IllegalArgumentException if any file is not a URL file * @throws IllegalArgumentException if any file is incorrectly encoded - * @since Commons IO 1.1 + * @since 1.1 */ public static File[] toFiles(URL[] urls) { if (urls == null || urls.length == 0) { @@ -734,9 +936,10 @@ *

    * Returns an array of the same size as the input. * - * @param files the files to convert + * @param files the files to convert, must not be {@code null} * @return an array of URLs matching the input * @throws IOException if a file cannot be converted + * @throws NullPointerException if the parameter is null */ public static URL[] toURLs(File[] files) throws IOException { URL[] urls = new URL[files.length]; @@ -762,8 +965,8 @@ * it is not guaranteed that the operation will succeed. * If the modification operation fails, no indication is provided. * - * @param srcFile an existing file to copy, must not be null - * @param destDir the directory to place the copy in, must not be null + * @param srcFile an existing file to copy, must not be {@code null} + * @param destDir the directory to place the copy in, must not be {@code null} * * @throws NullPointerException if source or destination is null * @throws IOException if source or destination is invalid @@ -783,21 +986,21 @@ * If the destination file exists, then this method will overwrite it. *

    * Note: Setting preserveFileDate to - * true tries to preserve the file's last modified + * {@code true} tries to preserve the file's last modified * date/times using {@link File#setLastModified(long)}, however it is * not guaranteed that the operation will succeed. * If the modification operation fails, no indication is provided. * - * @param srcFile an existing file to copy, must not be null - * @param destDir the directory to place the copy in, must not be null + * @param srcFile an existing file to copy, must not be {@code null} + * @param destDir the directory to place the copy in, must not be {@code null} * @param preserveFileDate true if the file date of the copy * should be the same as the original * - * @throws NullPointerException if source or destination is null + * @throws NullPointerException if source or destination is {@code null} * @throws IOException if source or destination is invalid * @throws IOException if an IO error occurs during copying * @see #copyFile(File, File, boolean) - * @since Commons IO 1.3 + * @since 1.3 */ public static void copyFileToDirectory(File srcFile, File destDir, boolean preserveFileDate) throws IOException { if (destDir == null) { @@ -823,10 +1026,10 @@ * it is not guaranteed that the operation will succeed. * If the modification operation fails, no indication is provided. * - * @param srcFile an existing file to copy, must not be null - * @param destFile the new file, must not be null + * @param srcFile an existing file to copy, must not be {@code null} + * @param destFile the new file, must not be {@code null} * - * @throws NullPointerException if source or destination is null + * @throws NullPointerException if source or destination is {@code null} * @throws IOException if source or destination is invalid * @throws IOException if an IO error occurs during copying * @see #copyFileToDirectory(File, File) @@ -844,17 +1047,17 @@ * If the destination file exists, then this method will overwrite it. *

    * Note: Setting preserveFileDate to - * true tries to preserve the file's last modified + * {@code true} tries to preserve the file's last modified * date/times using {@link File#setLastModified(long)}, however it is * not guaranteed that the operation will succeed. * If the modification operation fails, no indication is provided. * - * @param srcFile an existing file to copy, must not be null - * @param destFile the new file, must not be null + * @param srcFile an existing file to copy, must not be {@code null} + * @param destFile the new file, must not be {@code null} * @param preserveFileDate true if the file date of the copy * should be the same as the original * - * @throws NullPointerException if source or destination is null + * @throws NullPointerException if source or destination is {@code null} * @throws IOException if source or destination is invalid * @throws IOException if an IO error occurs during copying * @see #copyFileToDirectory(File, File, boolean) @@ -903,7 +1106,7 @@ * if the input or output is null * @throws IOException * if an I/O error occurs - * @since Commons IO 2.1 + * @since 2.1 */ public static long copyFile(File input, OutputStream output) throws IOException { final FileInputStream fis = new FileInputStream(input); @@ -917,8 +1120,8 @@ /** * Internal copy file method. * - * @param srcFile the validated source file, must not be null - * @param destFile the validated destination file, must not be null + * @param srcFile the validated source file, must not be {@code null} + * @param destFile the validated destination file, must not be {@code null} * @param preserveFileDate whether to preserve the file date * @throws IOException if an error occurs */ @@ -940,7 +1143,7 @@ long pos = 0; long count = 0; while (pos < size) { - count = (size - pos) > FILE_COPY_BUFFER_SIZE ? FILE_COPY_BUFFER_SIZE : (size - pos); + count = size - pos > FILE_COPY_BUFFER_SIZE ? FILE_COPY_BUFFER_SIZE : size - pos; pos += output.transferFrom(input, pos, count); } } finally { @@ -975,13 +1178,13 @@ * it is not guaranteed that those operations will succeed. * If the modification operation fails, no indication is provided. * - * @param srcDir an existing directory to copy, must not be null - * @param destDir the directory to place the copy in, must not be null + * @param srcDir an existing directory to copy, must not be {@code null} + * @param destDir the directory to place the copy in, must not be {@code null} * - * @throws NullPointerException if source or destination is null + * @throws NullPointerException if source or destination is {@code null} * @throws IOException if source or destination is invalid * @throws IOException if an IO error occurs during copying - * @since Commons IO 1.2 + * @since 1.2 */ public static void copyDirectoryToDirectory(File srcDir, File destDir) throws IOException { if (srcDir == null) { @@ -1015,13 +1218,13 @@ * it is not guaranteed that those operations will succeed. * If the modification operation fails, no indication is provided. * - * @param srcDir an existing directory to copy, must not be null - * @param destDir the new directory, must not be null + * @param srcDir an existing directory to copy, must not be {@code null} + * @param destDir the new directory, must not be {@code null} * - * @throws NullPointerException if source or destination is null + * @throws NullPointerException if source or destination is {@code null} * @throws IOException if source or destination is invalid * @throws IOException if an IO error occurs during copying - * @since Commons IO 1.1 + * @since 1.1 */ public static void copyDirectory(File srcDir, File destDir) throws IOException { copyDirectory(srcDir, destDir, true); @@ -1038,20 +1241,20 @@ * the source with the destination, with the source taking precedence. *

    * Note: Setting preserveFileDate to - * true tries to preserve the files' last modified + * {@code true} tries to preserve the files' last modified * date/times using {@link File#setLastModified(long)}, however it is * not guaranteed that those operations will succeed. * If the modification operation fails, no indication is provided. * - * @param srcDir an existing directory to copy, must not be null - * @param destDir the new directory, must not be null + * @param srcDir an existing directory to copy, must not be {@code null} + * @param destDir the new directory, must not be {@code null} * @param preserveFileDate true if the file date of the copy * should be the same as the original * - * @throws NullPointerException if source or destination is null + * @throws NullPointerException if source or destination is {@code null} * @throws IOException if source or destination is invalid * @throws IOException if an IO error occurs during copying - * @since Commons IO 1.1 + * @since 1.1 */ public static void copyDirectory(File srcDir, File destDir, boolean preserveFileDate) throws IOException { @@ -1092,15 +1295,15 @@ * FileUtils.copyDirectory(srcDir, destDir, filter); * * - * @param srcDir an existing directory to copy, must not be null - * @param destDir the new directory, must not be null + * @param srcDir an existing directory to copy, must not be {@code null} + * @param destDir the new directory, must not be {@code null} * @param filter the filter to apply, null means copy all directories and files * should be the same as the original * - * @throws NullPointerException if source or destination is null + * @throws NullPointerException if source or destination is {@code null} * @throws IOException if source or destination is invalid * @throws IOException if an IO error occurs during copying - * @since Commons IO 1.4 + * @since 1.4 */ public static void copyDirectory(File srcDir, File destDir, FileFilter filter) throws IOException { @@ -1118,7 +1321,7 @@ * the source with the destination, with the source taking precedence. *

    * Note: Setting preserveFileDate to - * true tries to preserve the files' last modified + * {@code true} tries to preserve the files' last modified * date/times using {@link File#setLastModified(long)}, however it is * not guaranteed that those operations will succeed. * If the modification operation fails, no indication is provided. @@ -1142,16 +1345,16 @@ * FileUtils.copyDirectory(srcDir, destDir, filter, false); * * - * @param srcDir an existing directory to copy, must not be null - * @param destDir the new directory, must not be null + * @param srcDir an existing directory to copy, must not be {@code null} + * @param destDir the new directory, must not be {@code null} * @param filter the filter to apply, null means copy all directories and files * @param preserveFileDate true if the file date of the copy * should be the same as the original * - * @throws NullPointerException if source or destination is null + * @throws NullPointerException if source or destination is {@code null} * @throws IOException if source or destination is invalid * @throws IOException if an IO error occurs during copying - * @since Commons IO 1.4 + * @since 1.4 */ public static void copyDirectory(File srcDir, File destDir, FileFilter filter, boolean preserveFileDate) throws IOException { @@ -1189,13 +1392,13 @@ /** * Internal copy directory method. * - * @param srcDir the validated source directory, must not be null - * @param destDir the validated destination directory, must not be null + * @param srcDir the validated source directory, must not be {@code null} + * @param destDir the validated destination directory, must not be {@code null} * @param filter the filter to apply, null means copy all directories and files * @param preserveFileDate whether to preserve the file date * @param exclusionList List of files and directories to exclude from the copy, may be null * @throws IOException if an error occurs - * @since Commons IO 1.1 + * @since 1.1 */ private static void doCopyDirectory(File srcDir, File destDir, FileFilter filter, boolean preserveFileDate, List exclusionList) throws IOException { @@ -1244,9 +1447,9 @@ * might block forever. Use {@link #copyURLToFile(URL, File, int, int)} * with reasonable timeouts to prevent this. * - * @param source the URL to copy bytes from, must not be null + * @param source the URL to copy bytes from, must not be {@code null} * @param destination the non-directory File to write bytes to - * (possibly overwriting), must not be null + * (possibly overwriting), must not be {@code null} * @throws IOException if source URL cannot be opened * @throws IOException if destination is a directory * @throws IOException if destination cannot be written @@ -1264,9 +1467,9 @@ * will be created if they don't already exist. destination * will be overwritten if it already exists. * - * @param source the URL to copy bytes from, must not be null + * @param source the URL to copy bytes from, must not be {@code null} * @param destination the non-directory File to write bytes to - * (possibly overwriting), must not be null + * (possibly overwriting), must not be {@code null} * @param connectionTimeout the number of milliseconds until this method * will timeout if no connection could be established to the source * @param readTimeout the number of milliseconds until this method will @@ -1276,7 +1479,7 @@ * @throws IOException if destination cannot be written * @throws IOException if destination needs creating but can't be * @throws IOException if an IO error occurs during copying - * @since Commons IO 2.0 + * @since 2.0 */ public static void copyURLToFile(URL source, File destination, int connectionTimeout, int readTimeout) throws IOException { @@ -1293,20 +1496,21 @@ * will be created if they don't already exist. destination * will be overwritten if it already exists. * - * @param source the InputStream to copy bytes from, must not be null + * @param source the InputStream to copy bytes from, must not be {@code null} * @param destination the non-directory File to write bytes to - * (possibly overwriting), must not be null + * (possibly overwriting), must not be {@code null} * @throws IOException if destination is a directory * @throws IOException if destination cannot be written * @throws IOException if destination needs creating but can't be * @throws IOException if an IO error occurs during copying - * @since Commons IO 2.0 + * @since 2.0 */ public static void copyInputStreamToFile(InputStream source, File destination) throws IOException { try { FileOutputStream output = openOutputStream(destination); try { IOUtils.copy(source, output); + output.close(); // don't swallow close Exception if copy completes normally } finally { IOUtils.closeQuietly(output); } @@ -1347,11 +1551,11 @@ *

  • No exceptions are thrown when a file or directory cannot be deleted.
  • * * - * @param file file or directory to delete, can be null - * @return true if the file or directory was deleted, otherwise - * false + * @param file file or directory to delete, can be {@code null} + * @return {@code true} if the file or directory was deleted, otherwise + * {@code false} * - * @since Commons IO 1.4 + * @since 1.4 */ public static boolean deleteQuietly(File file) { if (file == null) { @@ -1372,6 +1576,56 @@ } /** + * Determines whether the {@code parent} directory contains the {@code child} element (a file or directory). + *

    + * Files are normalized before comparison. + *

    + * + * Edge cases: + * + * + * @param directory + * the file to consider as the parent. + * @param child + * the file to consider as the child. + * @return true is the candidate leaf is under by the specified composite. False otherwise. + * @throws IOException + * if an IO error occurs while checking the files. + * @since 2.2 + * @see FilenameUtils#directoryContains(String, String) + */ + public static boolean directoryContains(final File directory, final File child) throws IOException { + + // Fail fast against NullPointerException + if (directory == null) { + throw new IllegalArgumentException("Directory must not be null"); + } + + if (!directory.isDirectory()) { + throw new IllegalArgumentException("Not a directory: " + directory); + } + + if (child == null) { + return false; + } + + if (!directory.exists() || !child.exists()) { + return false; + } + + // Canonicalize paths (normalizes relative paths) + String canonicalParent = directory.getCanonicalPath(); + String canonicalChild = child.getCanonicalPath(); + + return FilenameUtils.directoryContains(canonicalParent, canonicalChild); + } + + /** * Cleans a directory without deleting it. * * @param directory directory to clean @@ -1414,10 +1668,10 @@ * This method repeatedly tests {@link File#exists()} until it returns * true up to the maximum time specified in seconds. * - * @param file the file to check, must not be null + * @param file the file to check, must not be {@code null} * @param seconds the maximum time in seconds to wait * @return true if file exists - * @throws NullPointerException if the file is null + * @throws NullPointerException if the file is {@code null} */ public static boolean waitFor(File file, int seconds) { int timeout = 0; @@ -1445,44 +1699,63 @@ * Reads the contents of a file into a String. * The file is always closed. * - * @param file the file to read, must not be null - * @param encoding the encoding to use, null means platform default - * @return the file contents, never null + * @param file the file to read, must not be {@code null} + * @param encoding the encoding to use, {@code null} means platform default + * @return the file contents, never {@code null} * @throws IOException in case of an I/O error - * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM + * @since 2.3 */ - public static String readFileToString(File file, String encoding) throws IOException { + public static String readFileToString(File file, Charset encoding) throws IOException { InputStream in = null; try { in = openInputStream(file); - return IOUtils.toString(in, encoding); + return IOUtils.toString(in, Charsets.toCharset(encoding)); } finally { IOUtils.closeQuietly(in); } } + /** + * Reads the contents of a file into a String. The file is always closed. + * + * @param file + * the file to read, must not be {@code null} + * @param encoding + * the encoding to use, {@code null} means platform default + * @return the file contents, never {@code null} + * @throws IOException + * in case of an I/O error + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + * @since 2.3 + */ + public static String readFileToString(File file, String encoding) throws IOException { + return readFileToString(file, Charsets.toCharset(encoding)); + } + /** * 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, must not be null - * @return the file contents, never null + * @param file the file to read, must not be {@code null} + * @return the file contents, never {@code null} * @throws IOException in case of an I/O error - * @since Commons IO 1.3.1 + * @since 1.3.1 */ public static String readFileToString(File file) throws IOException { - return readFileToString(file, null); + return readFileToString(file, Charset.defaultCharset()); } /** * Reads the contents of a file into a byte array. * The file is always closed. * - * @param file the file to read, must not be null - * @return the file contents, never null + * @param file the file to read, must not be {@code null} + * @return the file contents, never {@code null} * @throws IOException in case of an I/O error - * @since Commons IO 1.1 + * @since 1.1 */ public static byte[] readFileToByteArray(File file) throws IOException { InputStream in = null; @@ -1498,34 +1771,52 @@ * Reads the contents of a file line by line to a List of Strings. * The file is always closed. * - * @param file the file to read, must not be null - * @param encoding the encoding to use, null means platform default - * @return the list of Strings representing each line in the file, never null + * @param file the file to read, must not be {@code null} + * @param encoding the encoding to use, {@code null} means platform default + * @return the list of Strings representing each line in the file, never {@code null} * @throws IOException in case of an I/O error - * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM - * @since Commons IO 1.1 + * @since 2.3 */ - public static List readLines(File file, String encoding) throws IOException { + public static List readLines(File file, Charset encoding) throws IOException { InputStream in = null; try { in = openInputStream(file); - return IOUtils.readLines(in, encoding); + return IOUtils.readLines(in, Charsets.toCharset(encoding)); } finally { IOUtils.closeQuietly(in); } } /** + * Reads the contents of a file line by line to a List of Strings. The file is always closed. + * + * @param file + * the file to read, must not be {@code null} + * @param encoding + * the encoding to use, {@code null} means platform default + * @return the list of Strings representing each line in the file, never {@code null} + * @throws IOException + * in case of an I/O error + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + * @since 1.1 + */ + public static List readLines(File file, String encoding) throws IOException { + return readLines(file, Charsets.toCharset(encoding)); + } + + /** * 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, must not be null - * @return the list of Strings representing each line in the file, never null + * @param file the file to read, must not be {@code null} + * @return the list of Strings representing each line in the file, never {@code null} * @throws IOException in case of an I/O error - * @since Commons IO 1.3 + * @since 1.3 */ public static List readLines(File file) throws IOException { - return readLines(file, null); + return readLines(file, Charset.defaultCharset()); } /** @@ -1553,11 +1844,11 @@ * If an exception occurs during the creation of the iterator, the * underlying stream is closed. * - * @param file the file to open for input, must not be null - * @param encoding the encoding to use, null means platform default - * @return an Iterator of the lines in the file, never null + * @param file the file to open for input, must not be {@code null} + * @param encoding the encoding to use, {@code null} means platform default + * @return an Iterator of the lines in the file, never {@code null} * @throws IOException in case of an I/O error (file closed) - * @since Commons IO 1.2 + * @since 1.2 */ public static LineIterator lineIterator(File file, String encoding) throws IOException { InputStream in = null; @@ -1576,10 +1867,10 @@ /** * Returns an Iterator for the lines in a File using the default encoding for the VM. * - * @param file the file to open for input, must not be null - * @return an Iterator of the lines in the file, never null + * @param file the file to open for input, must not be {@code null} + * @return an Iterator of the lines in the file, never {@code null} * @throws IOException in case of an I/O error (file closed) - * @since Commons IO 1.3 + * @since 1.3 * @see #lineIterator(File, String) */ public static LineIterator lineIterator(File file) throws IOException { @@ -1595,10 +1886,27 @@ * * @param file the file to write * @param data the content to write to the file - * @param encoding the encoding to use, null means platform default + * @param encoding the encoding to use, {@code null} means platform default * @throws IOException in case of an I/O error * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM + * @since 2.4 */ + public static void writeStringToFile(File file, String data, Charset encoding) throws IOException { + writeStringToFile(file, data, encoding, false); + } + + /** + * Writes a String to a file creating the file if it does not exist. + * + * NOTE: As from v1.3, the parent directories of the file will be created + * if they do not exist. + * + * @param file the file to write + * @param data the content to write to the file + * @param encoding the encoding to use, {@code null} means platform default + * @throws IOException in case of an I/O error + * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM + */ public static void writeStringToFile(File file, String data, String encoding) throws IOException { writeStringToFile(file, data, encoding, false); } @@ -1608,46 +1916,64 @@ * * @param file the file to write * @param data the content to write to the file - * @param encoding the encoding to use, null means platform default - * @param append if true, then the String will be added to the + * @param encoding the encoding to use, {@code null} means platform default + * @param append if {@code true}, then the String will be added to the * end of the file rather than overwriting * @throws IOException in case of an I/O error - * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM - * @since Commons IO 2.1 + * @since 2.3 */ - public static void writeStringToFile(File file, String data, String encoding, boolean append) throws IOException { + public static void writeStringToFile(File file, String data, Charset encoding, boolean append) throws IOException { OutputStream out = null; try { out = openOutputStream(file, append); IOUtils.write(data, out, encoding); + out.close(); // don't swallow close Exception if copy completes normally } finally { IOUtils.closeQuietly(out); } } /** + * Writes a String to a file creating the file if it does not exist. + * + * @param file the file to write + * @param data the content to write to the file + * @param encoding the encoding to use, {@code null} means platform default + * @param append if {@code true}, then the String will be added to the + * end of the file rather than overwriting + * @throws IOException in case of an I/O error + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported by the VM + * @since 2.1 + */ + public static void writeStringToFile(File file, String data, String encoding, boolean append) throws IOException { + writeStringToFile(file, data, Charsets.toCharset(encoding), append); + } + + /** * 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, false); + writeStringToFile(file, data, Charset.defaultCharset(), false); } /** * 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 - * @param append if true, then the String will be added to the + * @param append if {@code true}, then the String will be added to the * end of the file rather than overwriting * @throws IOException in case of an I/O error - * @since Commons IO 2.1 + * @since 2.1 */ public static void writeStringToFile(File file, String data, boolean append) throws IOException { - writeStringToFile(file, data, null, append); + writeStringToFile(file, data, Charset.defaultCharset(), append); } /** @@ -1656,35 +1982,48 @@ * @param file the file to write * @param data the content to write to the file * @throws IOException in case of an I/O error - * @since Commons IO 2.0 + * @since 2.0 */ public static void write(File file, CharSequence data) throws IOException { - write(file, data, null, false); + write(file, data, Charset.defaultCharset(), false); } /** * Writes a CharSequence 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 - * @param append if true, then the data will be added to the + * @param append if {@code true}, then the data will be added to the * end of the file rather than overwriting * @throws IOException in case of an I/O error - * @since Commons IO 2.1 + * @since 2.1 */ public static void write(File file, CharSequence data, boolean append) throws IOException { - write(file, data, null, append); + write(file, data, Charset.defaultCharset(), append); } /** * Writes a CharSequence to a file creating the file if it does not exist. * * @param file the file to write * @param data the content to write to the file - * @param encoding the encoding to use, null means platform default + * @param encoding the encoding to use, {@code null} means platform default * @throws IOException in case of an I/O error + * @since 2.3 + */ + public static void write(File file, CharSequence data, Charset encoding) throws IOException { + write(file, data, encoding, false); + } + + /** + * Writes a CharSequence to a file creating the file if it does not exist. + * + * @param file the file to write + * @param data the content to write to the file + * @param encoding the encoding to use, {@code null} means platform default + * @throws IOException in case of an I/O error * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM - * @since Commons IO 2.0 + * @since 2.0 */ public static void write(File file, CharSequence data, String encoding) throws IOException { write(file, data, encoding, false); @@ -1695,19 +2034,36 @@ * * @param file the file to write * @param data the content to write to the file - * @param encoding the encoding to use, null means platform default - * @param append if true, then the data will be added to the + * @param encoding the encoding to use, {@code null} means platform default + * @param append if {@code true}, then the data will be added to the * end of the file rather than overwriting * @throws IOException in case of an I/O error - * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM - * @since IO 2.1 + * @since 2.3 */ - public static void write(File file, CharSequence data, String encoding, boolean append) throws IOException { + public static void write(File file, CharSequence data, Charset encoding, boolean append) throws IOException { String str = data == null ? null : data.toString(); writeStringToFile(file, str, encoding, append); } /** + * Writes a CharSequence to a file creating the file if it does not exist. + * + * @param file the file to write + * @param data the content to write to the file + * @param encoding the encoding to use, {@code null} means platform default + * @param append if {@code true}, then the data will be added to the + * end of the file rather than overwriting + * @throws IOException in case of an I/O error + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported by the VM + * @since IO 2.1 + */ + public static void write(File file, CharSequence data, String encoding, boolean append) throws IOException { + write(file, data, Charsets.toCharset(encoding), append); + } + + /** * Writes a byte array to a file creating the file if it does not exist. *

    * NOTE: As from v1.3, the parent directories of the file will be created @@ -1716,7 +2072,7 @@ * @param file the file to write to * @param data the content to write to the file * @throws IOException in case of an I/O error - * @since Commons IO 1.1 + * @since 1.1 */ public static void writeByteArrayToFile(File file, byte[] data) throws IOException { writeByteArrayToFile(file, data, false); @@ -1727,7 +2083,7 @@ * * @param file the file to write to * @param data the content to write to the file - * @param append if true, then bytes will be added to the + * @param append if {@code true}, then bytes will be added to the * end of the file rather than overwriting * @throws IOException in case of an I/O error * @since IO 2.1 @@ -1737,6 +2093,7 @@ try { out = openOutputStream(file, append); out.write(data); + out.close(); // don't swallow close Exception if copy completes normally } finally { IOUtils.closeQuietly(out); } @@ -1751,11 +2108,11 @@ * if they do not exist. * * @param file the file to write to - * @param encoding the encoding to use, null means platform default - * @param lines the lines to write, null entries produce blank lines + * @param encoding the encoding to use, {@code null} means platform default + * @param lines the lines to write, {@code null} entries produce blank lines * @throws IOException in case of an I/O error * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM - * @since Commons IO 1.1 + * @since 1.1 */ public static void writeLines(File file, String encoding, Collection lines) throws IOException { writeLines(file, encoding, lines, null, false); @@ -1767,13 +2124,13 @@ * The specified character encoding and the default line ending will be used. * * @param file the file to write to - * @param encoding the encoding to use, null means platform default - * @param lines the lines to write, null entries produce blank lines - * @param append if true, then the lines will be added to the + * @param encoding the encoding to use, {@code null} means platform default + * @param lines the lines to write, {@code null} entries produce blank lines + * @param append if {@code true}, then the lines will be added to the * end of the file rather than overwriting * @throws IOException in case of an I/O error * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM - * @since Commons IO 2.1 + * @since 2.1 */ public static void writeLines(File file, String encoding, Collection lines, boolean append) throws IOException { writeLines(file, encoding, lines, null, append); @@ -1785,9 +2142,9 @@ * 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 + * @param lines the lines to write, {@code null} entries produce blank lines * @throws IOException in case of an I/O error - * @since Commons IO 1.3 + * @since 1.3 */ public static void writeLines(File file, Collection lines) throws IOException { writeLines(file, null, lines, null, false); @@ -1799,11 +2156,11 @@ * 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 - * @param append if true, then the lines will be added to the + * @param lines the lines to write, {@code null} entries produce blank lines + * @param append if {@code true}, then the lines will be added to the * end of the file rather than overwriting * @throws IOException in case of an I/O error - * @since Commons IO 2.1 + * @since 2.1 */ public static void writeLines(File file, Collection lines, boolean append) throws IOException { writeLines(file, null, lines, null, append); @@ -1818,12 +2175,12 @@ * if they do not exist. * * @param file the file to write to - * @param encoding the encoding to use, null means platform default - * @param lines the lines to write, null entries produce blank lines - * @param lineEnding the line separator to use, null is system default + * @param encoding the encoding to use, {@code null} means platform default + * @param lines the lines to write, {@code null} entries produce blank lines + * @param lineEnding the line separator to use, {@code null} is system default * @throws IOException in case of an I/O error * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM - * @since Commons IO 1.1 + * @since 1.1 */ public static void writeLines(File file, String encoding, Collection lines, String lineEnding) throws IOException { @@ -1836,21 +2193,24 @@ * The specified character encoding and the line ending will be used. * * @param file the file to write to - * @param encoding the encoding to use, null means platform default - * @param lines the lines to write, null entries produce blank lines - * @param lineEnding the line separator to use, null is system default - * @param append if true, then the lines will be added to the + * @param encoding the encoding to use, {@code null} means platform default + * @param lines the lines to write, {@code null} entries produce blank lines + * @param lineEnding the line separator to use, {@code null} is system default + * @param append if {@code true}, then the lines will be added to the * end of the file rather than overwriting * @throws IOException in case of an I/O error * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM - * @since Commons IO 2.1 + * @since 2.1 */ public static void writeLines(File file, String encoding, Collection lines, String lineEnding, boolean append) - throws IOException { - OutputStream out = null; + throws IOException { + FileOutputStream out = null; try { out = openOutputStream(file, append); - IOUtils.writeLines(lines, lineEnding, out, encoding); + final BufferedOutputStream buffer = new BufferedOutputStream(out); + IOUtils.writeLines(lines, lineEnding, buffer, encoding); + buffer.flush(); + out.close(); // don't swallow close Exception if copy completes normally } finally { IOUtils.closeQuietly(out); } @@ -1862,10 +2222,10 @@ * 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 + * @param lines the lines to write, {@code null} entries produce blank lines + * @param lineEnding the line separator to use, {@code null} is system default * @throws IOException in case of an I/O error - * @since Commons IO 1.3 + * @since 1.3 */ public static void writeLines(File file, Collection lines, String lineEnding) throws IOException { writeLines(file, null, lines, lineEnding, false); @@ -1877,12 +2237,12 @@ * 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 - * @param append if true, then the lines will be added to the + * @param lines the lines to write, {@code null} entries produce blank lines + * @param lineEnding the line separator to use, {@code null} is system default + * @param append if {@code true}, then the lines will be added to the * end of the file rather than overwriting * @throws IOException in case of an I/O error - * @since Commons IO 2.1 + * @since 2.1 */ public static void writeLines(File file, Collection lines, String lineEnding, boolean append) throws IOException { @@ -1900,8 +2260,8 @@ * (java.io.File methods returns a boolean) * * - * @param file file or directory to delete, must not be null - * @throws NullPointerException if the directory is null + * @param file file or directory to delete, must not be {@code null} + * @throws NullPointerException if the directory is {@code null} * @throws FileNotFoundException if the file was not found * @throws IOException in case deletion is unsuccessful */ @@ -1925,8 +2285,8 @@ * Schedules a file to be deleted when JVM exits. * If file is directory delete it and all sub-directories. * - * @param file file or directory to delete, must not be null - * @throws NullPointerException if the file is null + * @param file file or directory to delete, must not be {@code null} + * @throws NullPointerException if the file is {@code null} * @throws IOException in case deletion is unsuccessful */ public static void forceDeleteOnExit(File file) throws IOException { @@ -1940,26 +2300,26 @@ /** * Schedules a directory recursively for deletion on JVM exit. * - * @param directory directory to delete, must not be null - * @throws NullPointerException if the directory is null + * @param directory directory to delete, must not be {@code null} + * @throws NullPointerException if the directory is {@code null} * @throws IOException in case deletion is unsuccessful */ private static void deleteDirectoryOnExit(File directory) throws IOException { if (!directory.exists()) { return; } + directory.deleteOnExit(); if (!isSymlink(directory)) { cleanDirectoryOnExit(directory); } - directory.deleteOnExit(); } /** * Cleans a directory without deleting it. * - * @param directory directory to clean, must not be null - * @throws NullPointerException if the directory is null + * @param directory directory to clean, must not be {@code null} + * @throws NullPointerException if the directory is {@code null} * @throws IOException in case cleaning is unsuccessful */ private static void cleanDirectoryOnExit(File directory) throws IOException { @@ -1999,8 +2359,8 @@ * If the directory cannot be created (or does not already exist) * then an IOException is thrown. * - * @param directory directory to create, must not be null - * @throws NullPointerException if the directory is null + * @param directory directory to create, must not be {@code null} + * @throws NullPointerException if the directory is {@code null} * @throws IOException if the directory cannot be created or the file already exists but is not a directory */ public static void forceMkdir(File directory) throws IOException { @@ -2036,15 +2396,15 @@ * restricted, its size will not be included. * * @param file the regular file or directory to return the size - * of (must not be null). + * of (must not be {@code null}). * * @return the length of the file, or recursive size of the directory, * provided (in bytes). * - * @throws NullPointerException if the file is null + * @throws NullPointerException if the file is {@code null} * @throws IllegalArgumentException if the file does not exist. * - * @since Commons IO 2.0 + * @since 2.0 */ public static long sizeOf(File file) { @@ -2062,49 +2422,133 @@ } /** - * Counts the size of a directory recursively (sum of the length of all files). - * - * @param directory directory to inspect, must not be null - * @return size of directory in bytes, 0 if directory is security restricted - * @throws NullPointerException if the directory is null + * Returns the size of the specified file or directory. If the provided + * {@link File} is a regular file, then the file's length is returned. + * If the argument is a directory, then the size of the directory is + * calculated recursively. If a directory or subdirectory is security + * restricted, its size will not be included. + * + * @param file the regular file or directory to return the size + * of (must not be {@code null}). + * + * @return the length of the file, or recursive size of the directory, + * provided (in bytes). + * + * @throws NullPointerException if the file is {@code null} + * @throws IllegalArgumentException if the file does not exist. + * + * @since 2.4 */ - public static long sizeOfDirectory(File directory) { - if (!directory.exists()) { - String message = directory + " does not exist"; + public static BigInteger sizeOfAsBigInteger(File file) { + + if (!file.exists()) { + String message = file + " does not exist"; throw new IllegalArgumentException(message); } - if (!directory.isDirectory()) { - String message = directory + " is not a directory"; - throw new IllegalArgumentException(message); + if (file.isDirectory()) { + return sizeOfDirectoryAsBigInteger(file); + } else { + return BigInteger.valueOf(file.length()); } - long size = 0; + } - File[] files = directory.listFiles(); + /** + * Counts the size of a directory recursively (sum of the length of all files). + * + * @param directory + * directory to inspect, must not be {@code null} + * @return size of directory in bytes, 0 if directory is security restricted, a negative number when the real total + * is greater than {@link Long#MAX_VALUE}. + * @throws NullPointerException + * if the directory is {@code null} + */ + public static long sizeOfDirectory(File directory) { + checkDirectory(directory); + + final File[] files = directory.listFiles(); if (files == null) { // null if security restricted return 0L; } - for (File file : files) { - size += sizeOf(file); + long size = 0; + + for (final File file : files) { + try { + if (!isSymlink(file)) { + size += sizeOf(file); + if (size < 0) { + break; + } + } + } catch (IOException ioe) { + // Ignore exceptions caught when asking if a File is a symlink. + } } return size; } + /** + * Counts the size of a directory recursively (sum of the length of all files). + * + * @param directory + * directory to inspect, must not be {@code null} + * @return size of directory in bytes, 0 if directory is security restricted. + * @throws NullPointerException + * if the directory is {@code null} + * @since 2.4 + */ + public static BigInteger sizeOfDirectoryAsBigInteger(File directory) { + checkDirectory(directory); + + final File[] files = directory.listFiles(); + if (files == null) { // null if security restricted + return BigInteger.ZERO; + } + BigInteger size = BigInteger.ZERO; + + for (final File file : files) { + try { + if (!isSymlink(file)) { + size = size.add(BigInteger.valueOf(sizeOf(file))); + } + } catch (IOException ioe) { + // Ignore exceptions caught when asking if a File is a symlink. + } + } + + return size; + } + + /** + * Checks that the given {@code File} exists and is a directory. + * + * @param directory The {@code File} to check. + * @throws IllegalArgumentException if the given {@code File} does not exist or is not a directory. + */ + private static void checkDirectory(File directory) { + if (!directory.exists()) { + throw new IllegalArgumentException(directory + " does not exist"); + } + if (!directory.isDirectory()) { + throw new IllegalArgumentException(directory + " is not a directory"); + } + } + //----------------------------------------------------------------------- /** * Tests if the specified File is newer than the reference * File. * * @param file the File of which the modification date must - * be compared, must not be null + * be compared, must not be {@code null} * @param reference the File of which the modification date - * is used, must not be null + * is used, must not be {@code null} * @return true if the File exists and has been modified more * recently than the reference File - * @throws IllegalArgumentException if the file is null - * @throws IllegalArgumentException if the reference file is null or doesn't exist + * @throws IllegalArgumentException if the file is {@code null} + * @throws IllegalArgumentException if the reference file is {@code null} or doesn't exist */ public static boolean isFileNewer(File file, File reference) { if (reference == null) { @@ -2122,12 +2566,12 @@ * Date. * * @param file the File of which the modification date - * must be compared, must not be null - * @param date the date reference, must not be null + * must be compared, must not be {@code null} + * @param date the date reference, must not be {@code null} * @return true if the File exists and has been modified * after the given Date. - * @throws IllegalArgumentException if the file is null - * @throws IllegalArgumentException if the date is null + * @throws IllegalArgumentException if the file is {@code null} + * @throws IllegalArgumentException if the date is {@code null} */ public static boolean isFileNewer(File file, Date date) { if (date == null) { @@ -2141,12 +2585,12 @@ * time reference. * * @param file the File of which the modification date must - * be compared, must not be null + * be compared, must not be {@code null} * @param timeMillis the time reference measured in milliseconds since the * epoch (00:00:00 GMT, January 1, 1970) * @return true if the File exists and has been modified after * the given time reference. - * @throws IllegalArgumentException if the file is null + * @throws IllegalArgumentException if the file is {@code null} */ public static boolean isFileNewer(File file, long timeMillis) { if (file == null) { @@ -2165,13 +2609,13 @@ * File. * * @param file the File of which the modification date must - * be compared, must not be null + * be compared, must not be {@code null} * @param reference the File of which the modification date - * is used, must not be null + * is used, must not be {@code null} * @return true if the File exists and has been modified before * the reference File - * @throws IllegalArgumentException if the file is null - * @throws IllegalArgumentException if the reference file is null or doesn't exist + * @throws IllegalArgumentException if the file is {@code null} + * @throws IllegalArgumentException if the reference file is {@code null} or doesn't exist */ public static boolean isFileOlder(File file, File reference) { if (reference == null) { @@ -2189,12 +2633,12 @@ * Date. * * @param file the File of which the modification date - * must be compared, must not be null - * @param date the date reference, must not be null + * must be compared, must not be {@code null} + * @param date the date reference, must not be {@code null} * @return true if the File exists and has been modified * before the given Date. - * @throws IllegalArgumentException if the file is null - * @throws IllegalArgumentException if the date is null + * @throws IllegalArgumentException if the file is {@code null} + * @throws IllegalArgumentException if the date is {@code null} */ public static boolean isFileOlder(File file, Date date) { if (date == null) { @@ -2208,12 +2652,12 @@ * time reference. * * @param file the File of which the modification date must - * be compared, must not be null + * be compared, must not be {@code null} * @param timeMillis the time reference measured in milliseconds since the * epoch (00:00:00 GMT, January 1, 1970) * @return true if the File exists and has been modified before * the given time reference. - * @throws IllegalArgumentException if the file is null + * @throws IllegalArgumentException if the file is {@code null} */ public static boolean isFileOlder(File file, long timeMillis) { if (file == null) { @@ -2230,12 +2674,12 @@ * Computes the checksum of a file using the CRC32 checksum routine. * The value of the checksum is returned. * - * @param file the file to checksum, must not be null + * @param file the file to checksum, must not be {@code null} * @return the checksum value - * @throws NullPointerException if the file or checksum is null + * @throws NullPointerException if the file or checksum is {@code null} * @throws IllegalArgumentException if the file is a directory * @throws IOException if an IO error occurs reading the file - * @since Commons IO 1.3 + * @since 1.3 */ public static long checksumCRC32(File file) throws IOException { CRC32 crc = new CRC32(); @@ -2252,13 +2696,13 @@ * long csum = FileUtils.checksum(file, new CRC32()).getValue(); * * - * @param file the file to checksum, must not be null - * @param checksum the checksum object to be used, must not be null + * @param file the file to checksum, must not be {@code null} + * @param checksum the checksum object to be used, must not be {@code null} * @return the checksum specified, updated with the content of the file - * @throws NullPointerException if the file or checksum is null + * @throws NullPointerException if the file or checksum is {@code null} * @throws IllegalArgumentException if the file is a directory * @throws IOException if an IO error occurs reading the file - * @since Commons IO 1.3 + * @since 1.3 */ public static Checksum checksum(File file, Checksum checksum) throws IOException { if (file.isDirectory()) { @@ -2281,11 +2725,11 @@ * * @param srcDir the directory to be moved * @param destDir the destination directory - * @throws NullPointerException if source or destination is null + * @throws NullPointerException if source or destination is {@code null} * @throws FileExistsException if the destination directory exists * @throws IOException if source or destination is invalid * @throws IOException if an IO error occurs moving the file - * @since Commons IO 1.4 + * @since 1.4 */ public static void moveDirectory(File srcDir, File destDir) throws IOException { if (srcDir == null) { @@ -2305,6 +2749,9 @@ } boolean rename = srcDir.renameTo(destDir); if (!rename) { + if (destDir.getCanonicalPath().startsWith(srcDir.getCanonicalPath())) { + throw new IOException("Cannot move directory: "+srcDir+" to a subdirectory of itself: "+destDir); + } copyDirectory( srcDir, destDir ); deleteDirectory( srcDir ); if (srcDir.exists()) { @@ -2319,13 +2766,13 @@ * * @param src the file to be moved * @param destDir the destination file - * @param createDestDir If true create the destination directory, - * otherwise if false throw an IOException - * @throws NullPointerException if source or destination is null + * @param createDestDir If {@code true} create the destination directory, + * otherwise if {@code false} throw an IOException + * @throws NullPointerException if source or destination is {@code null} * @throws FileExistsException if the directory exists in the destination directory * @throws IOException if source or destination is invalid * @throws IOException if an IO error occurs moving the file - * @since Commons IO 1.4 + * @since 1.4 */ public static void moveDirectoryToDirectory(File src, File destDir, boolean createDestDir) throws IOException { if (src == null) { @@ -2355,11 +2802,11 @@ * * @param srcFile the file to be moved * @param destFile the destination file - * @throws NullPointerException if source or destination is null + * @throws NullPointerException if source or destination is {@code null} * @throws FileExistsException if the destination file exists * @throws IOException if source or destination is invalid * @throws IOException if an IO error occurs moving the file - * @since Commons IO 1.4 + * @since 1.4 */ public static void moveFile(File srcFile, File destFile) throws IOException { if (srcFile == null) { @@ -2396,13 +2843,13 @@ * * @param srcFile the file to be moved * @param destDir the destination file - * @param createDestDir If true create the destination directory, - * otherwise if false throw an IOException - * @throws NullPointerException if source or destination is null + * @param createDestDir If {@code true} create the destination directory, + * otherwise if {@code false} throw an IOException + * @throws NullPointerException if source or destination is {@code null} * @throws FileExistsException if the destination file exists * @throws IOException if source or destination is invalid * @throws IOException if an IO error occurs moving the file - * @since Commons IO 1.4 + * @since 1.4 */ public static void moveFileToDirectory(File srcFile, File destDir, boolean createDestDir) throws IOException { if (srcFile == null) { @@ -2431,13 +2878,13 @@ * * @param src the file or directory to be moved * @param destDir the destination directory - * @param createDestDir If true create the destination directory, - * otherwise if false throw an IOException - * @throws NullPointerException if source or destination is null + * @param createDestDir If {@code true} create the destination directory, + * otherwise if {@code false} throw an IOException + * @throws NullPointerException if source or destination is {@code null} * @throws FileExistsException if the directory or file exists in the destination directory * @throws IOException if source or destination is invalid * @throws IOException if an IO error occurs moving the file - * @since Commons IO 1.4 + * @since 1.4 */ public static void moveToDirectory(File src, File destDir, boolean createDestDir) throws IOException { if (src == null) { @@ -2461,11 +2908,14 @@ *

    * Will not return true if there is a Symbolic Link anywhere in the path, * only if the specific file is. - * + *

    + * Note: the current implementation always returns {@code false} if the system + * is detected as Windows using {@link FilenameUtils#isSystemWindows()} + * * @param file the file to check * @return true if the file is a Symbolic Link * @throws IOException if an IO error occurs while checking the file - * @since Commons IO 2.0 + * @since 2.0 */ public static boolean isSymlink(File file) throws IOException { if (file == null) { @@ -2488,4 +2938,5 @@ return true; } } + } Index: 3rdParty_sources/commons-io/org/apache/commons/io/FilenameUtils.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/FilenameUtils.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/FilenameUtils.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/FilenameUtils.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -17,6 +17,7 @@ package org.apache.commons.io; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Stack; @@ -76,30 +77,20 @@ *

    * Origin of code: Excalibur, Alexandria, Tomcat, Commons-Utils. * - * @author Kevin A. Burton - * @author Scott Sanders - * @author Daniel Rall - * @author Christoph.Reck - * @author Peter Donald - * @author Jeff Turner - * @author Matthew Hawthorne - * @author Martin Cooper - * @author Jeremias Maerki - * @author Stephen Colebourne * @version $Id$ - * @since Commons IO 1.1 + * @since 1.1 */ public class FilenameUtils { /** * The extension separator character. - * @since Commons IO 1.4 + * @since 1.4 */ public static final char EXTENSION_SEPARATOR = '.'; /** * The extension separator String. - * @since Commons IO 1.4 + * @since 1.4 */ public static final String EXTENSION_SEPARATOR_STR = Character.toString(EXTENSION_SEPARATOR); @@ -155,7 +146,7 @@ * @return true if it is a separator character */ private static boolean isSeparator(char ch) { - return (ch == UNIX_SEPARATOR) || (ch == WINDOWS_SEPARATOR); + return ch == UNIX_SEPARATOR || ch == WINDOWS_SEPARATOR; } //----------------------------------------------------------------------- @@ -170,7 +161,7 @@ * A double slash will be merged to a single slash (but UNC names are handled). * A single dot path segment will be removed. * A double dot will cause that path segment and the one before to be removed. - * If the double dot has no parent path segment to work with, null + * If the double dot has no parent path segment to work with, {@code null} * is returned. *

    * The output will be the same on both Unix and Windows except @@ -213,7 +204,7 @@ * A double slash will be merged to a single slash (but UNC names are handled). * A single dot path segment will be removed. * A double dot will cause that path segment and the one before to be removed. - * If the double dot has no parent path segment to work with, null + * If the double dot has no parent path segment to work with, {@code null} * is returned. *

    * The output will be the same on both Unix and Windows except @@ -241,13 +232,13 @@ * the separator character. * * @param filename the filename to normalize, null returns null - * @param unixSeparator true if a unix separator should - * be used or false if a windows separator should be used. + * @param unixSeparator {@code true} if a unix separator should + * be used or {@code false} if a windows separator should be used. * @return the normalized filename, or null if invalid - * @since Commons IO 2.0 + * @since 2.0 */ public static String normalize(String filename, boolean unixSeparator) { - char separator = (unixSeparator ? UNIX_SEPARATOR : WINDOWS_SEPARATOR); + char separator = unixSeparator ? UNIX_SEPARATOR : WINDOWS_SEPARATOR; return doNormalize(filename, separator, true); } @@ -264,7 +255,7 @@ * A double slash will be merged to a single slash (but UNC names are handled). * A single dot path segment will be removed. * A double dot will cause that path segment and the one before to be removed. - * If the double dot has no parent path segment to work with, null + * If the double dot has no parent path segment to work with, {@code null} * is returned. *

    * The output will be the same on both Unix and Windows except @@ -309,7 +300,7 @@ * A double slash will be merged to a single slash (but UNC names are handled). * A single dot path segment will be removed. * A double dot will cause that path segment and the one before to be removed. - * If the double dot has no parent path segment to work with, null + * If the double dot has no parent path segment to work with, {@code null} * is returned. *

    * The output will be the same on both Unix and Windows including @@ -335,13 +326,13 @@ * * * @param filename the filename to normalize, null returns null - * @param unixSeparator true if a unix separator should - * be used or false if a windows separtor should be used. + * @param unixSeparator {@code true} if a unix separator should + * be used or {@code false} if a windows separtor should be used. * @return the normalized filename, or null if invalid - * @since Commons IO 2.0 + * @since 2.0 */ public static String normalizeNoEndSeparator(String filename, boolean unixSeparator) { - char separator = (unixSeparator ? UNIX_SEPARATOR : WINDOWS_SEPARATOR); + char separator = unixSeparator ? UNIX_SEPARATOR : WINDOWS_SEPARATOR; return doNormalize(filename, separator, false); } @@ -370,7 +361,7 @@ filename.getChars(0, filename.length(), array, 0); // fix separators throughout - char otherSeparator = (separator == SYSTEM_SEPARATOR ? OTHER_SEPARATOR : SYSTEM_SEPARATOR); + char otherSeparator = separator == SYSTEM_SEPARATOR ? OTHER_SEPARATOR : SYSTEM_SEPARATOR; for (int i = 0; i < array.length; i++) { if (array[i] == otherSeparator) { array[i] = separator; @@ -422,14 +413,14 @@ if (array[j] == separator) { // remove b/../ from a/b/../c System.arraycopy(array, i + 1, array, j + 1, size - i); - size -= (i - j); + size -= i - j; i = j + 1; continue outer; } } // remove a/../ from a/../c System.arraycopy(array, i + 1, array, prefix, size - i); - size -= (i + 1 - prefix); + size -= i + 1 - prefix; i = prefix + 1; } } @@ -510,6 +501,48 @@ } } + /** + * Determines whether the {@code parent} directory contains the {@code child} element (a file or directory). + *

    + * The files names are expected to be normalized. + *

    + * + * Edge cases: + *
      + *
    • A {@code directory} must not be null: if null, throw IllegalArgumentException
    • + *
    • A directory does not contain itself: return false
    • + *
    • A null child file is not contained in any parent: return false
    • + *
    + * + * @param canonicalParent + * the file to consider as the parent. + * @param canonicalChild + * the file to consider as the child. + * @return true is the candidate leaf is under by the specified composite. False otherwise. + * @throws IOException + * if an IO error occurs while checking the files. + * @since 2.2 + * @see FileUtils#directoryContains(File, File) + */ + public static boolean directoryContains(final String canonicalParent, final String canonicalChild) + throws IOException { + + // Fail fast against NullPointerException + if (canonicalParent == null) { + throw new IllegalArgumentException("Directory must not be null"); + } + + if (canonicalChild == null) { + return false; + } + + if (IOCase.SYSTEM.checkEquals(canonicalParent, canonicalChild)) { + return false; + } + + return IOCase.SYSTEM.checkStartsWith(canonicalChild, canonicalParent); + } + //----------------------------------------------------------------------- /** * Converts all separators to the Unix separator of forward slash. @@ -602,16 +635,16 @@ if (ch0 == '~') { return 2; // return a length greater than the input } - return (isSeparator(ch0) ? 1 : 0); + return isSeparator(ch0) ? 1 : 0; } else { if (ch0 == '~') { int posUnix = filename.indexOf(UNIX_SEPARATOR, 1); int posWin = filename.indexOf(WINDOWS_SEPARATOR, 1); if (posUnix == -1 && posWin == -1) { return len + 1; // return a length greater than the input } - posUnix = (posUnix == -1 ? posWin : posUnix); - posWin = (posWin == -1 ? posUnix : posWin); + posUnix = posUnix == -1 ? posWin : posUnix; + posWin = posWin == -1 ? posUnix : posWin; return Math.min(posUnix, posWin) + 1; } char ch1 = filename.charAt(1); @@ -628,14 +661,14 @@ } else if (isSeparator(ch0) && isSeparator(ch1)) { int posUnix = filename.indexOf(UNIX_SEPARATOR, 2); int posWin = filename.indexOf(WINDOWS_SEPARATOR, 2); - if ((posUnix == -1 && posWin == -1) || posUnix == 2 || posWin == 2) { + if (posUnix == -1 && posWin == -1 || posUnix == 2 || posWin == 2) { return -1; } - posUnix = (posUnix == -1 ? posWin : posUnix); - posWin = (posWin == -1 ? posUnix : posWin); + posUnix = posUnix == -1 ? posWin : posUnix; + posWin = posWin == -1 ? posUnix : posWin; return Math.min(posUnix, posWin) + 1; } else { - return (isSeparator(ch0) ? 1 : 0); + return isSeparator(ch0) ? 1 : 0; } } } @@ -680,7 +713,7 @@ } int extensionPos = filename.lastIndexOf(EXTENSION_SEPARATOR); int lastSeparator = indexOfLastSeparator(filename); - return (lastSeparator > extensionPos ? -1 : extensionPos); + return lastSeparator > extensionPos ? -1 : extensionPos; } //----------------------------------------------------------------------- @@ -956,8 +989,8 @@ * The output will be the same irrespective of the machine that the code is running on. * * @param filename the filename to retrieve the extension of. - * @return the extension of the file or an empty string if none exists or null - * if the filename is null. + * @return the extension of the file or an empty string if none exists or {@code null} + * if the filename is {@code null}. */ public static String getExtension(String filename) { if (filename == null) { @@ -1074,14 +1107,14 @@ * @param normalized whether to normalize the filenames * @param caseSensitivity what case sensitivity rule to use, null means case-sensitive * @return true if the filenames are equal, null equals null - * @since Commons IO 1.3 + * @since 1.3 */ public static boolean equals( String filename1, String filename2, boolean normalized, IOCase caseSensitivity) { if (filename1 == null || filename2 == null) { - return (filename1 == null && filename2 == null); + return filename1 == null && filename2 == null; } if (normalized) { filename1 = normalize(filename1); @@ -1114,7 +1147,7 @@ return false; } if (extension == null || extension.length() == 0) { - return (indexOfExtension(filename) == -1); + return indexOfExtension(filename) == -1; } String fileExt = getExtension(filename); return fileExt.equals(extension); @@ -1136,7 +1169,7 @@ return false; } if (extensions == null || extensions.length == 0) { - return (indexOfExtension(filename) == -1); + return indexOfExtension(filename) == -1; } String fileExt = getExtension(filename); for (String extension : extensions) { @@ -1163,7 +1196,7 @@ return false; } if (extensions == null || extensions.isEmpty()) { - return (indexOfExtension(filename) == -1); + return indexOfExtension(filename) == -1; } String fileExt = getExtension(filename); for (String extension : extensions) { @@ -1239,7 +1272,7 @@ * @param wildcardMatcher the wildcard string to match against * @param caseSensitivity what case sensitivity rule to use, null means case-sensitive * @return true if the filename matches the wilcard string - * @since Commons IO 1.3 + * @since 1.3 */ public static boolean wildcardMatch(String filename, String wildcardMatcher, IOCase caseSensitivity) { if (filename == null && wildcardMatcher == null) { @@ -1350,8 +1383,8 @@ } if (array[i] == '?') { list.add("?"); - } else if (list.size() == 0 || - (i > 0 && list.get(list.size() - 1).equals("*") == false)) { + } else if (list.isEmpty() || + i > 0 && list.get(list.size() - 1).equals("*") == false) { list.add("*"); } } else { Index: 3rdParty_sources/commons-io/org/apache/commons/io/HexDump.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/HexDump.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/HexDump.java 1 Oct 2012 13:03:03 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/HexDump.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -27,8 +27,6 @@ *

    * Origin of code: POI. * - * @author Scott Sanders - * @author Marc Johnson * @version $Id$ */ public class HexDump { @@ -75,7 +73,7 @@ throws IOException, ArrayIndexOutOfBoundsException, IllegalArgumentException { - if ((index < 0) || (index >= data.length)) { + if (index < 0 || index >= data.length) { throw new ArrayIndexOutOfBoundsException( "illegal index: " + index + " into array of length " + data.length); @@ -102,7 +100,7 @@ buffer.append(' '); } for (int k = 0; k < chars_read; k++) { - if ((data[k + j] >= ' ') && (data[k + j] < 127)) { + if (data[k + j] >= ' ' && data[k + j] < 127) { buffer.append((char) data[k + j]); } else { buffer.append('.'); @@ -141,7 +139,7 @@ private static StringBuilder dump(StringBuilder _lbuffer, long value) { for (int j = 0; j < 8; j++) { _lbuffer - .append(_hexcodes[((int) (value >> _shifts[j])) & 15]); + .append(_hexcodes[(int) (value >> _shifts[j]) & 15]); } return _lbuffer; } @@ -155,7 +153,7 @@ */ private static StringBuilder dump(StringBuilder _cbuffer, byte value) { for (int j = 0; j < 2; j++) { - _cbuffer.append(_hexcodes[(value >> _shifts[j + 6]) & 15]); + _cbuffer.append(_hexcodes[value >> _shifts[j + 6] & 15]); } return _cbuffer; } Index: 3rdParty_sources/commons-io/org/apache/commons/io/IOCase.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/IOCase.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/IOCase.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/IOCase.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -31,9 +31,8 @@ * Wherever possible, you should use the check methods in this * class to compare filenames. * - * @author Stephen Colebourne * @version $Id$ - * @since Commons IO 1.3 + * @since 1.3 */ public final class IOCase implements Serializable { @@ -211,9 +210,9 @@ * @param strStartIndex the index to start at in str * @param search the start to search for, not null * @return the first index of the search String, - * -1 if no match or null string input + * -1 if no match or {@code null} string input * @throws NullPointerException if either string is null - * @since Commons IO 2.0 + * @since 2.0 */ public int checkIndexOf(String str, int strStartIndex, String search) { int endIndex = str.length() - search.length(); Index: 3rdParty_sources/commons-io/org/apache/commons/io/IOExceptionWithCause.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/IOExceptionWithCause.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/IOExceptionWithCause.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/IOExceptionWithCause.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -23,9 +23,8 @@ * Subclasses IOException with the {@link Throwable} constructors missing before Java 6. If you are using Java 6, * consider this class deprecated and use {@link IOException}. * - * @author Apache Commons IO * @version $Id$ - * @since Commons IO 1.4 + * @since 1.4 */ public class IOExceptionWithCause extends IOException { @@ -44,7 +43,7 @@ * @param message * the message (see {@link #getMessage()}) * @param cause - * the cause (see {@link #getCause()}). A null value is allowed. + * the cause (see {@link #getCause()}). A {@code null} value is allowed. */ public IOExceptionWithCause(String message, Throwable cause) { super(message); @@ -59,7 +58,7 @@ *

    * * @param cause - * the cause (see {@link #getCause()}). A null value is allowed. + * the cause (see {@link #getCause()}). A {@code null} value is allowed. */ public IOExceptionWithCause(Throwable cause) { super(cause == null ? null : cause.toString()); Index: 3rdParty_sources/commons-io/org/apache/commons/io/IOUtils.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/IOUtils.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/IOUtils.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/IOUtils.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -30,10 +30,17 @@ import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Reader; +import java.io.UnsupportedEncodingException; import java.io.Writer; +import java.net.HttpURLConnection; +import java.net.ServerSocket; import java.net.Socket; import java.net.URI; import java.net.URL; +import java.net.URLConnection; +import java.nio.channels.Selector; +import java.nio.charset.Charset; +import java.nio.charset.UnsupportedCharsetException; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -72,20 +79,14 @@ *

    * Origin of code: Excalibur. * - * @author Peter Donald - * @author Jeff Turner - * @author Matthew Hawthorne - * @author Stephen Colebourne - * @author Gareth Davis - * @author Ian Springer - * @author Sandy McArthur * @version $Id$ */ public class IOUtils { // NOTE: This class is focussed on InputStream, OutputStream, Reader and // Writer. Each method should take at least one of these as a parameter, // or return one of them. + private static final int EOF = -1; /** * The Unix directory separator character. */ @@ -110,6 +111,7 @@ * The system line separator string. */ public static final String LINE_SEPARATOR; + static { // avoid security issues StringBuilderWriter buf = new StringBuilderWriter(4); @@ -120,7 +122,7 @@ } /** - * The default buffer size to use for + * The default buffer size ({@value}) to use for * {@link #copyLarge(InputStream, OutputStream)} * and * {@link #copyLarge(Reader, Writer)} @@ -132,7 +134,14 @@ */ private static final int SKIP_BUFFER_SIZE = 2048; - // Allocated in the skip method if necessary. + // Allocated in the relevant skip method if necessary. + /* + * N.B. no need to synchronize these because: + * - we don't care if the buffer is created multiple times (the data is ignored) + * - we always use the same size buffer, so if it it is recreated it will still be OK + * (if the buffer size were variable, we would need to synch. to ensure some other thread + * did not create a smaller one) + */ private static char[] SKIP_CHAR_BUFFER; private static byte[] SKIP_BYTE_BUFFER; @@ -144,7 +153,20 @@ } //----------------------------------------------------------------------- + /** + * Closes a URLConnection. + * + * @param conn the connection to close. + * @since 2.4 + */ + public static void close(URLConnection conn) { + if (conn instanceof HttpURLConnection) { + ((HttpURLConnection) conn).disconnect(); + } + } + + /** * Unconditionally close an Reader. *

    * Equivalent to {@link Reader#close()}, except any exceptions will be ignored. @@ -273,7 +295,7 @@ * * * @param closeable the object to close, may be null or already closed - * @since Commons IO 2.0 + * @since 2.0 */ public static void closeQuietly(Closeable closeable) { try { @@ -306,7 +328,7 @@ * * * @param sock the Socket to close, may be null or already closed - * @since Commons IO 2.0 + * @since 2.0 */ public static void closeQuietly(Socket sock){ if (sock != null){ @@ -319,6 +341,72 @@ } /** + * Unconditionally close a Selector. + *

    + * Equivalent to {@link Selector#close()}, except any exceptions will be ignored. + * This is typically used in finally blocks. + *

    + * Example code: + *

    +     *   Selector selector = null;
    +     *   try {
    +     *       selector = Selector.open();
    +     *       // process socket
    +     *       
    +     *   } catch (Exception e) {
    +     *       // error handling
    +     *   } finally {
    +     *       IOUtils.closeQuietly(selector);
    +     *   }
    +     * 
    + * + * @param selector the Selector to close, may be null or already closed + * @since 2.2 + */ + public static void closeQuietly(Selector selector){ + if (selector != null){ + try { + selector.close(); + } catch (IOException ioe) { + // ignored + } + } + } + + /** + * Unconditionally close a ServerSocket. + *

    + * Equivalent to {@link ServerSocket#close()}, except any exceptions will be ignored. + * This is typically used in finally blocks. + *

    + * Example code: + *

    +     *   ServerSocket socket = null;
    +     *   try {
    +     *       socket = new ServerSocket();
    +     *       // process socket
    +     *       socket.close();
    +     *   } catch (Exception e) {
    +     *       // error handling
    +     *   } finally {
    +     *       IOUtils.closeQuietly(socket);
    +     *   }
    +     * 
    + * + * @param sock the ServerSocket to close, may be null or already closed + * @since 2.2 + */ + public static void closeQuietly(ServerSocket sock){ + if (sock != null){ + try { + sock.close(); + } catch (IOException ioe) { + // ignored + } + } + } + + /** * Fetches entire contents of an InputStream and represent * same data as result InputStream. *

    @@ -337,12 +425,25 @@ * @param input Stream to be fully buffered. * @return A fully buffered stream. * @throws IOException if an I/O error occurs - * @since Commons IO 2.0 + * @since 2.0 */ public static InputStream toBufferedInputStream(InputStream input) throws IOException { return ByteArrayOutputStream.toBufferedInputStream(input); } + /** + * Returns the given reader if it is a {@link BufferedReader}, otherwise creates a toBufferedReader for the given + * reader. + * + * @param reader + * the reader to wrap or return + * @return the given reader or a new {@link BufferedReader} for the given reader + * @since 2.2 + */ + public static BufferedReader toBufferedReader(Reader reader) { + return reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader); + } + // read toByteArray //----------------------------------------------------------------------- /** @@ -376,7 +477,7 @@ * @throws IOException if an I/O error occurs or InputStream size differ from parameter size * @throws IllegalArgumentException if size is less than zero or size is greater than Integer.MAX_VALUE * @see IOUtils#toByteArray(java.io.InputStream, int) - * @since Commons IO 2.1 + * @since 2.1 */ public static byte[] toByteArray(InputStream input, long size) throws IOException { @@ -396,27 +497,27 @@ * @return the requested byte array * @throws IOException if an I/O error occurs or InputStream size differ from parameter size * @throws IllegalArgumentException if size is less than zero - * @since Commons IO 2.1 + * @since 2.1 */ public static byte[] toByteArray(InputStream input, int size) throws IOException { - if(size < 0) { + if (size < 0) { throw new IllegalArgumentException("Size must be equal or greater than zero: " + size); } - - if(size == 0) { + + if (size == 0) { return new byte[0]; } byte[] data = new byte[size]; int offset = 0; int readed; - while(offset < size && (readed = input.read(data, offset, (size - offset))) != -1) { + while (offset < size && (readed = input.read(data, offset, size - offset)) != EOF) { offset += readed; } - if(offset != size) { + if (offset != size) { throw new IOException("Unexpected readed size. current: " + offset + ", excepted: " + size); } @@ -436,8 +537,26 @@ * @throws IOException if an I/O error occurs */ public static byte[] toByteArray(Reader input) throws IOException { + return toByteArray(input, Charset.defaultCharset()); + } + + /** + * Get the contents of a Reader as a byte[] + * using the specified character encoding. + *

    + * This method buffers the input internally, so there is no need to use a + * BufferedReader. + * + * @param input the Reader to read from + * @param encoding the encoding to use, null means platform default + * @return the requested byte array + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static byte[] toByteArray(Reader input, Charset encoding) throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); - copy(input, output); + copy(input, output, encoding); return output.toByteArray(); } @@ -456,13 +575,13 @@ * @return the requested byte array * @throws NullPointerException if the input is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + * @since 1.1 */ - public static byte[] toByteArray(Reader input, String encoding) - throws IOException { - ByteArrayOutputStream output = new ByteArrayOutputStream(); - copy(input, output, encoding); - return output.toByteArray(); + public static byte[] toByteArray(Reader input, String encoding) throws IOException { + return toByteArray(input, Charsets.toCharset(encoding)); } /** @@ -482,6 +601,64 @@ return input.getBytes(); } + /** + * Get the contents of a URI as a byte[]. + * + * @param uri + * the URI to read + * @return the requested byte array + * @throws NullPointerException + * if the uri is null + * @throws IOException + * if an I/O exception occurs + * @since 2.4 + */ + public static byte[] toByteArray(URI uri) throws IOException { + return IOUtils.toByteArray(uri.toURL()); + } + + /** + * Get the contents of a URL as a byte[]. + * + * @param url + * the URL to read + * @return the requested byte array + * @throws NullPointerException + * if the input is null + * @throws IOException + * if an I/O exception occurs + * @since 2.4 + */ + public static byte[] toByteArray(URL url) throws IOException { + URLConnection conn = url.openConnection(); + try { + return IOUtils.toByteArray(conn); + } finally { + close(conn); + } + } + + /** + * Get the contents of a URLConnection as a byte[]. + * + * @param urlConn + * the URLConnection to read + * @return the requested byte array + * @throws NullPointerException + * if the urlConn is null + * @throws IOException + * if an I/O exception occurs + * @since 2.4 + */ + public static byte[] toByteArray(URLConnection urlConn) throws IOException { + InputStream inputStream = urlConn.getInputStream(); + try { + return IOUtils.toByteArray(inputStream); + } finally { + inputStream.close(); + } + } + // read char[] //----------------------------------------------------------------------- /** @@ -495,11 +672,30 @@ * @return the requested character array * @throws NullPointerException if the input is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 */ public static char[] toCharArray(InputStream is) throws IOException { + return toCharArray(is, Charset.defaultCharset()); + } + + /** + * Get the contents of an InputStream as a character array + * using the specified character encoding. + *

    + * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + * + * @param is the InputStream to read from + * @param encoding the encoding to use, null means platform default + * @return the requested character array + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static char[] toCharArray(InputStream is, Charset encoding) + throws IOException { CharArrayWriter output = new CharArrayWriter(); - copy(is, output); + copy(is, output, encoding); return output.toCharArray(); } @@ -518,13 +714,13 @@ * @return the requested character array * @throws NullPointerException if the input is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + * @since 1.1 */ - public static char[] toCharArray(InputStream is, String encoding) - throws IOException { - CharArrayWriter output = new CharArrayWriter(); - copy(is, output, encoding); - return output.toCharArray(); + public static char[] toCharArray(InputStream is, String encoding) throws IOException { + return toCharArray(is, Charsets.toCharset(encoding)); } /** @@ -537,7 +733,7 @@ * @return the requested character array * @throws NullPointerException if the input is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 */ public static char[] toCharArray(Reader input) throws IOException { CharArrayWriter sw = new CharArrayWriter(); @@ -560,13 +756,33 @@ * @throws IOException if an I/O error occurs */ public static String toString(InputStream input) throws IOException { - return toString(input, null); + return toString(input, Charset.defaultCharset()); } /** * Get the contents of an InputStream as a String * using the specified character encoding. *

    + * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + *

    + * @param input the InputStream to read from + * @param encoding the encoding to use, null means platform default + * @return the requested String + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static String toString(InputStream input, Charset encoding) throws IOException { + StringBuilderWriter sw = new StringBuilderWriter(); + copy(input, sw, encoding); + return sw.toString(); + } + + /** + * Get the contents of an InputStream as a String + * using the specified character encoding. + *

    * Character encoding names can be found at * IANA. *

    @@ -578,12 +794,13 @@ * @return the requested String * @throws NullPointerException if the input is null * @throws IOException if an I/O error occurs + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. */ public static String toString(InputStream input, String encoding) throws IOException { - StringBuilderWriter sw = new StringBuilderWriter(); - copy(input, sw, encoding); - return sw.toString(); + return toString(input, Charsets.toCharset(encoding)); } /** @@ -610,10 +827,10 @@ * The URI source. * @return The contents of the URL as a String. * @throws IOException if an I/O exception occurs. - * @since 2.1. + * @since 2.1 */ public static String toString(URI uri) throws IOException { - return toString(uri, null); + return toString(uri, Charset.defaultCharset()); } /** @@ -625,10 +842,28 @@ * The encoding name for the URL contents. * @return The contents of the URL as a String. * @throws IOException if an I/O exception occurs. - * @since 2.1. + * @since 2.3. */ + public static String toString(URI uri, Charset encoding) throws IOException { + return toString(uri.toURL(), Charsets.toCharset(encoding)); + } + + /** + * Gets the contents at the given URI. + * + * @param uri + * The URI source. + * @param encoding + * The encoding name for the URL contents. + * @return The contents of the URL as a String. + * @throws IOException if an I/O exception occurs. + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + * @since 2.1 + */ public static String toString(URI uri, String encoding) throws IOException { - return toString(uri.toURL(), encoding); + return toString(uri, Charsets.toCharset(encoding)); } /** @@ -638,10 +873,10 @@ * The URL source. * @return The contents of the URL as a String. * @throws IOException if an I/O exception occurs. - * @since 2.1. + * @since 2.1 */ public static String toString(URL url) throws IOException { - return toString(url, null); + return toString(url, Charset.defaultCharset()); } /** @@ -653,9 +888,9 @@ * The encoding name for the URL contents. * @return The contents of the URL as a String. * @throws IOException if an I/O exception occurs. - * @since 2.1. + * @since 2.3 */ - public static String toString(URL url, String encoding) throws IOException { + public static String toString(URL url, Charset encoding) throws IOException { InputStream inputStream = url.openStream(); try { return toString(inputStream, encoding); @@ -665,6 +900,24 @@ } /** + * Gets the contents at the given URL. + * + * @param url + * The URL source. + * @param encoding + * The encoding name for the URL contents. + * @return The contents of the URL as a String. + * @throws IOException if an I/O exception occurs. + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + * @since 2.1 + */ + public static String toString(URL url, String encoding) throws IOException { + return toString(url, Charsets.toCharset(encoding)); + } + + /** * Get the contents of a byte[] as a String * using the default character encoding of the platform. * @@ -691,16 +944,9 @@ * @return the requested String * @throws NullPointerException if the input is null * @throws IOException if an I/O error occurs (never occurs) - * @deprecated Use {@link String#String(byte[],String)} */ - @Deprecated - public static String toString(byte[] input, String encoding) - throws IOException { - if (encoding == null) { - return new String(input); - } else { - return new String(input, encoding); - } + public static String toString(byte[] input, String encoding) throws IOException { + return new String(input, Charsets.toCharset(encoding)); } // readLines @@ -716,10 +962,28 @@ * @return the list of Strings, never null * @throws NullPointerException if the input is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 */ public static List readLines(InputStream input) throws IOException { - InputStreamReader reader = new InputStreamReader(input); + return readLines(input, Charset.defaultCharset()); + } + + /** + * Get the contents of an InputStream as a list of Strings, + * one entry per line, using the specified character encoding. + *

    + * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + * + * @param input the InputStream to read from, not null + * @param encoding the encoding to use, null means platform default + * @return the list of Strings, never null + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static List readLines(InputStream input, Charset encoding) throws IOException { + InputStreamReader reader = new InputStreamReader(input, Charsets.toCharset(encoding)); return readLines(reader); } @@ -738,15 +1002,13 @@ * @return the list of Strings, never null * @throws NullPointerException if the input is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + * @since 1.1 */ public static List readLines(InputStream input, String encoding) throws IOException { - if (encoding == null) { - return readLines(input); - } else { - InputStreamReader reader = new InputStreamReader(input, encoding); - return readLines(reader); - } + return readLines(input, Charsets.toCharset(encoding)); } /** @@ -760,10 +1022,10 @@ * @return the list of Strings, never null * @throws NullPointerException if the input is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 */ public static List readLines(Reader input) throws IOException { - BufferedReader reader = new BufferedReader(input); + BufferedReader reader = toBufferedReader(input); List list = new ArrayList(); String line = reader.readLine(); while (line != null) { @@ -800,7 +1062,7 @@ * @param reader the Reader to read from, not null * @return an Iterator of the lines in the reader, never null * @throws IllegalArgumentException if the reader is null - * @since Commons IO 1.2 + * @since 1.2 */ public static LineIterator lineIterator(Reader reader) { return new LineIterator(reader); @@ -819,6 +1081,40 @@ * The recommended usage pattern is: *

          * try {
    +     *   LineIterator it = IOUtils.lineIterator(stream, charset);
    +     *   while (it.hasNext()) {
    +     *     String line = it.nextLine();
    +     *     /// do something with line
    +     *   }
    +     * } finally {
    +     *   IOUtils.closeQuietly(stream);
    +     * }
    +     * 
    + * + * @param input the InputStream to read from, not null + * @param encoding the encoding to use, null means platform default + * @return an Iterator of the lines in the reader, never null + * @throws IllegalArgumentException if the input is null + * @throws IOException if an I/O error occurs, such as if the encoding is invalid + * @since 2.3 + */ + public static LineIterator lineIterator(InputStream input, Charset encoding) throws IOException { + return new LineIterator(new InputStreamReader(input, Charsets.toCharset(encoding))); + } + + /** + * Return an Iterator for the lines in an InputStream, using + * the character encoding specified (or default encoding if null). + *

    + * LineIterator holds a reference to the open + * InputStream specified here. When you have finished with + * the iterator you should close the stream to free internal resources. + * This can be done by closing the stream directly, or by calling + * {@link LineIterator#close()} or {@link LineIterator#closeQuietly(LineIterator)}. + *

    + * The recommended usage pattern is: + *

    +     * try {
          *   LineIterator it = IOUtils.lineIterator(stream, "UTF-8");
          *   while (it.hasNext()) {
          *     String line = it.nextLine();
    @@ -834,17 +1130,13 @@
          * @return an Iterator of the lines in the reader, never null
          * @throws IllegalArgumentException if the input is null
          * @throws IOException if an I/O error occurs, such as if the encoding is invalid
    -     * @since Commons IO 1.2
    +     * @throws UnsupportedCharsetException
    +     *             thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not
    +     *             supported.
    +     * @since 1.2
          */
    -    public static LineIterator lineIterator(InputStream input, String encoding) 
    -                     throws IOException {
    -        Reader reader = null;
    -        if (encoding == null) {
    -            reader = new InputStreamReader(input);
    -        } else {
    -            reader = new InputStreamReader(input, encoding);
    -        }
    -        return new LineIterator(reader);
    +    public static LineIterator lineIterator(InputStream input, String encoding) throws IOException {
    +        return lineIterator(input, Charsets.toCharset(encoding));
         }
     
         //-----------------------------------------------------------------------
    @@ -854,27 +1146,43 @@
          *
          * @param input the CharSequence to convert
          * @return an input stream
    -     * @since Commons IO 2.0
    +     * @since 2.0
          */
         public static InputStream toInputStream(CharSequence input) {
    -        return toInputStream(input.toString());
    +        return toInputStream(input, Charset.defaultCharset());
         }
     
         /**
          * Convert the specified CharSequence to an input stream, encoded as bytes
          * using the specified character encoding.
    +     *
    +     * @param input the CharSequence to convert
    +     * @param encoding the encoding to use, null means platform default
    +     * @return an input stream
    +     * @since 2.3
    +     */
    +    public static InputStream toInputStream(CharSequence input, Charset encoding) {
    +        return toInputStream(input.toString(), encoding);
    +    }
    +
    +    /**
    +     * Convert the specified CharSequence to an input stream, encoded as bytes
    +     * using the specified character encoding.
          * 

    * Character encoding names can be found at * IANA. * * @param input the CharSequence to convert * @param encoding the encoding to use, null means platform default - * @throws IOException if the encoding is invalid * @return an input stream - * @since Commons IO 2.0 + * @throws IOException if the encoding is invalid + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + * @since 2.0 */ public static InputStream toInputStream(CharSequence input, String encoding) throws IOException { - return toInputStream(input.toString(), encoding); + return toInputStream(input, Charsets.toCharset(encoding)); } //----------------------------------------------------------------------- @@ -884,28 +1192,43 @@ * * @param input the string to convert * @return an input stream - * @since Commons IO 1.1 + * @since 1.1 */ public static InputStream toInputStream(String input) { - byte[] bytes = input.getBytes(); - return new ByteArrayInputStream(bytes); + return toInputStream(input, Charset.defaultCharset()); } /** * Convert the specified string to an input stream, encoded as bytes * using the specified character encoding. + * + * @param input the string to convert + * @param encoding the encoding to use, null means platform default + * @return an input stream + * @since 2.3 + */ + public static InputStream toInputStream(String input, Charset encoding) { + return new ByteArrayInputStream(input.getBytes(Charsets.toCharset(encoding))); + } + + /** + * Convert the specified string to an input stream, encoded as bytes + * using the specified character encoding. *

    * Character encoding names can be found at * IANA. * * @param input the string to convert * @param encoding the encoding to use, null means platform default - * @throws IOException if the encoding is invalid * @return an input stream - * @since Commons IO 1.1 + * @throws IOException if the encoding is invalid + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + * @since 1.1 */ public static InputStream toInputStream(String input, String encoding) throws IOException { - byte[] bytes = encoding != null ? input.getBytes(encoding) : input.getBytes(); + byte[] bytes = input.getBytes(Charsets.toCharset(encoding)); return new ByteArrayInputStream(bytes); } @@ -919,7 +1242,7 @@ * @param output the OutputStream to write to * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 */ public static void write(byte[] data, OutputStream output) throws IOException { @@ -939,11 +1262,29 @@ * @param output the Writer to write to * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 */ public static void write(byte[] data, Writer output) throws IOException { + write(data, output, Charset.defaultCharset()); + } + + /** + * Writes bytes from a byte[] to chars on a Writer + * using the specified character encoding. + *

    + * This method uses {@link String#String(byte[], String)}. + * + * @param data the byte array to write, do not modify during output, + * null ignored + * @param output the Writer to write to + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static void write(byte[] data, Writer output, Charset encoding) throws IOException { if (data != null) { - output.write(new String(data)); + output.write(new String(data, Charsets.toCharset(encoding))); } } @@ -962,17 +1303,13 @@ * @param encoding the encoding to use, null means platform default * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + * @since 1.1 */ - public static void write(byte[] data, Writer output, String encoding) - throws IOException { - if (data != null) { - if (encoding == null) { - write(data, output); - } else { - output.write(new String(data, encoding)); - } - } + public static void write(byte[] data, Writer output, String encoding) throws IOException { + write(data, output, Charsets.toCharset(encoding)); } // write char[] @@ -986,7 +1323,7 @@ * @param output the Writer to write to * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 */ public static void write(char[] data, Writer output) throws IOException { if (data != null) { @@ -1006,12 +1343,31 @@ * @param output the OutputStream to write to * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 */ public static void write(char[] data, OutputStream output) throws IOException { + write(data, output, Charset.defaultCharset()); + } + + /** + * Writes chars from a char[] to bytes on an + * OutputStream using the specified character encoding. + *

    + * This method uses {@link String#String(char[])} and + * {@link String#getBytes(String)}. + * + * @param data the char array to write, do not modify during output, + * null ignored + * @param output the OutputStream to write to + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static void write(char[] data, OutputStream output, Charset encoding) throws IOException { if (data != null) { - output.write(new String(data).getBytes()); + output.write(new String(data).getBytes(Charsets.toCharset(encoding))); } } @@ -1031,17 +1387,14 @@ * @param encoding the encoding to use, null means platform default * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + * @since 1.1 */ public static void write(char[] data, OutputStream output, String encoding) throws IOException { - if (data != null) { - if (encoding == null) { - write(data, output); - } else { - output.write(new String(data).getBytes(encoding)); - } - } + write(data, output, Charsets.toCharset(encoding)); } // write CharSequence @@ -1053,7 +1406,7 @@ * @param output the Writer to write to * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs - * @since Commons IO 2.0 + * @since 2.0 */ public static void write(CharSequence data, Writer output) throws IOException { if (data != null) { @@ -1072,12 +1425,29 @@ * @param output the OutputStream to write to * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs - * @since Commons IO 2.0 + * @since 2.0 */ public static void write(CharSequence data, OutputStream output) throws IOException { + write(data, output, Charset.defaultCharset()); + } + + /** + * Writes chars from a CharSequence to bytes on an + * OutputStream using the specified character encoding. + *

    + * This method uses {@link String#getBytes(String)}. + * + * @param data the CharSequence to write, null ignored + * @param output the OutputStream to write to + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static void write(CharSequence data, OutputStream output, Charset encoding) throws IOException { if (data != null) { - write(data.toString(), output); + write(data.toString(), output, encoding); } } @@ -1095,13 +1465,13 @@ * @param encoding the encoding to use, null means platform default * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs - * @since Commons IO 2.0 + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + * @since 2.0 */ - public static void write(CharSequence data, OutputStream output, String encoding) - throws IOException { - if (data != null) { - write(data.toString(), output, encoding); - } + public static void write(CharSequence data, OutputStream output, String encoding) throws IOException { + write(data, output, Charsets.toCharset(encoding)); } // write String @@ -1113,7 +1483,7 @@ * @param output the Writer to write to * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 */ public static void write(String data, Writer output) throws IOException { if (data != null) { @@ -1132,12 +1502,29 @@ * @param output the OutputStream to write to * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 */ public static void write(String data, OutputStream output) throws IOException { + write(data, output, Charset.defaultCharset()); + } + + /** + * Writes chars from a String to bytes on an + * OutputStream using the specified character encoding. + *

    + * This method uses {@link String#getBytes(String)}. + * + * @param data the String to write, null ignored + * @param output the OutputStream to write to + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static void write(String data, OutputStream output, Charset encoding) throws IOException { if (data != null) { - output.write(data.getBytes()); + output.write(data.getBytes(Charsets.toCharset(encoding))); } } @@ -1155,17 +1542,14 @@ * @param encoding the encoding to use, null means platform default * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + * @since 1.1 */ public static void write(String data, OutputStream output, String encoding) throws IOException { - if (data != null) { - if (encoding == null) { - write(data, output); - } else { - output.write(data.getBytes(encoding)); - } - } + write(data, output, Charsets.toCharset(encoding)); } // write StringBuffer @@ -1177,7 +1561,7 @@ * @param output the Writer to write to * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 * @deprecated replaced by write(CharSequence, Writer) */ @Deprecated @@ -1199,15 +1583,13 @@ * @param output the OutputStream to write to * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 * @deprecated replaced by write(CharSequence, OutputStream) */ @Deprecated public static void write(StringBuffer data, OutputStream output) throws IOException { - if (data != null) { - output.write(data.toString().getBytes()); - } + write(data, output, (String) null); } /** @@ -1224,18 +1606,16 @@ * @param encoding the encoding to use, null means platform default * @throws NullPointerException if output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + * @since 1.1 * @deprecated replaced by write(CharSequence, OutputStream, String) */ @Deprecated - public static void write(StringBuffer data, OutputStream output, - String encoding) throws IOException { + public static void write(StringBuffer data, OutputStream output, String encoding) throws IOException { if (data != null) { - if (encoding == null) { - write(data, output); - } else { - output.write(data.toString().getBytes(encoding)); - } + output.write(data.toString().getBytes(Charsets.toCharset(encoding))); } } @@ -1251,21 +1631,40 @@ * @param output the OutputStream to write to, not null, not closed * @throws NullPointerException if the output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 */ public static void writeLines(Collection lines, String lineEnding, OutputStream output) throws IOException { + writeLines(lines, lineEnding, output, Charset.defaultCharset()); + } + + /** + * Writes the toString() value of each item in a collection to + * an OutputStream line by line, using the specified character + * encoding and the specified line ending. + * + * @param lines the lines to write, null entries produce blank lines + * @param lineEnding the line separator to use, null is system default + * @param output the OutputStream to write to, not null, not closed + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if the output is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static void writeLines(Collection lines, String lineEnding, OutputStream output, Charset encoding) + throws IOException { if (lines == null) { return; } if (lineEnding == null) { lineEnding = LINE_SEPARATOR; } + Charset cs = Charsets.toCharset(encoding); for (Object line : lines) { if (line != null) { - output.write(line.toString().getBytes()); + output.write(line.toString().getBytes(cs)); } - output.write(lineEnding.getBytes()); + output.write(lineEnding.getBytes(cs)); } } @@ -1283,26 +1682,14 @@ * @param encoding the encoding to use, null means platform default * @throws NullPointerException if the output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + * @since 1.1 */ public static void writeLines(Collection lines, String lineEnding, OutputStream output, String encoding) throws IOException { - if (encoding == null) { - writeLines(lines, lineEnding, output); - } else { - if (lines == null) { - return; - } - if (lineEnding == null) { - lineEnding = LINE_SEPARATOR; - } - for (Object line : lines) { - if (line != null) { - output.write(line.toString().getBytes(encoding)); - } - output.write(lineEnding.getBytes(encoding)); - } - } + writeLines(lines, lineEnding, output, Charsets.toCharset(encoding)); } /** @@ -1314,7 +1701,7 @@ * @param writer the Writer to write to, not null, not closed * @throws NullPointerException if the input is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 */ public static void writeLines(Collection lines, String lineEnding, Writer writer) throws IOException { @@ -1351,7 +1738,7 @@ * @return the number of bytes copied, or -1 if > Integer.MAX_VALUE * @throws NullPointerException if the input or output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 */ public static int copy(InputStream input, OutputStream output) throws IOException { long count = copyLarge(input, output); @@ -1367,27 +1754,119 @@ *

    * This method buffers the input internally, so there is no need to use a * BufferedInputStream. + *

    + * The buffer size is given by {@link #DEFAULT_BUFFER_SIZE}. * * @param input the InputStream to read from * @param output the OutputStream to write to * @return the number of bytes copied * @throws NullPointerException if the input or output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.3 + * @since 1.3 */ public static long copyLarge(InputStream input, OutputStream output) throws IOException { - byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; + return copyLarge(input, output, new byte[DEFAULT_BUFFER_SIZE]); + } + + /** + * Copy bytes from a large (over 2GB) InputStream to an + * OutputStream. + *

    + * This method uses the provided buffer, so there is no need to use a + * BufferedInputStream. + *

    + * + * @param input the InputStream to read from + * @param output the OutputStream to write to + * @param buffer the buffer to use for the copy + * @return the number of bytes copied + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 2.2 + */ + public static long copyLarge(InputStream input, OutputStream output, byte[] buffer) + throws IOException { long count = 0; int n = 0; - while (-1 != (n = input.read(buffer))) { + while (EOF != (n = input.read(buffer))) { output.write(buffer, 0, n); count += n; } return count; } /** + * Copy some or all bytes from a large (over 2GB) InputStream to an + * OutputStream, optionally skipping input bytes. + *

    + * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + *

    + * The buffer size is given by {@link #DEFAULT_BUFFER_SIZE}. + * + * @param input the InputStream to read from + * @param output the OutputStream to write to + * @param inputOffset : number of bytes to skip from input before copying + * -ve values are ignored + * @param length : number of bytes to copy. -ve means all + * @return the number of bytes copied + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 2.2 + */ + public static long copyLarge(InputStream input, OutputStream output, long inputOffset, long length) + throws IOException { + return copyLarge(input, output, inputOffset, length, new byte[DEFAULT_BUFFER_SIZE]); + } + + /** + * Copy some or all bytes from a large (over 2GB) InputStream to an + * OutputStream, optionally skipping input bytes. + *

    + * This method uses the provided buffer, so there is no need to use a + * BufferedInputStream. + *

    + * + * @param input the InputStream to read from + * @param output the OutputStream to write to + * @param inputOffset : number of bytes to skip from input before copying + * -ve values are ignored + * @param length : number of bytes to copy. -ve means all + * @param buffer the buffer to use for the copy + * + * @return the number of bytes copied + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 2.2 + */ + public static long copyLarge(InputStream input, OutputStream output, + final long inputOffset, final long length, byte[] buffer) throws IOException { + if (inputOffset > 0) { + skipFully(input, inputOffset); + } + if (length == 0) { + return 0; + } + final int bufferLength = buffer.length; + int bytesToRead = bufferLength; + if (length > 0 && length < bufferLength) { + bytesToRead = (int) length; + } + int read; + long totalRead = 0; + while (bytesToRead > 0 && EOF != (read = input.read(buffer, 0, bytesToRead))) { + output.write(buffer, 0, read); + totalRead += read; + if (length > 0) { // only adjust length if not reading to the end + // Note the cast must work because buffer.length is an integer + bytesToRead = (int) Math.min(length - totalRead, bufferLength); + } + } + return totalRead; + } + + /** * Copy bytes from an InputStream to chars on a * Writer using the default character encoding of the platform. *

    @@ -1400,11 +1879,31 @@ * @param output the Writer to write to * @throws NullPointerException if the input or output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 */ public static void copy(InputStream input, Writer output) throws IOException { - InputStreamReader in = new InputStreamReader(input); + copy(input, output, Charset.defaultCharset()); + } + + /** + * Copy bytes from an InputStream to chars on a + * Writer using the specified character encoding. + *

    + * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + *

    + * This method uses {@link InputStreamReader}. + * + * @param input the InputStream to read from + * @param output the Writer to write to + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static void copy(InputStream input, Writer output, Charset encoding) throws IOException { + InputStreamReader in = new InputStreamReader(input, Charsets.toCharset(encoding)); copy(in, output); } @@ -1425,16 +1924,13 @@ * @param encoding the encoding to use, null means platform default * @throws NullPointerException if the input or output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + * @since 1.1 */ - public static void copy(InputStream input, Writer output, String encoding) - throws IOException { - if (encoding == null) { - copy(input, output); - } else { - InputStreamReader in = new InputStreamReader(input, encoding); - copy(in, output); - } + public static void copy(InputStream input, Writer output, String encoding) throws IOException { + copy(input, output, Charsets.toCharset(encoding)); } // copy from Reader @@ -1455,7 +1951,7 @@ * @return the number of characters copied, or -1 if > Integer.MAX_VALUE * @throws NullPointerException if the input or output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 */ public static int copy(Reader input, Writer output) throws IOException { long count = copyLarge(input, output); @@ -1470,26 +1966,114 @@ *

    * This method buffers the input internally, so there is no need to use a * BufferedReader. + *

    + * The buffer size is given by {@link #DEFAULT_BUFFER_SIZE}. * * @param input the Reader to read from * @param output the Writer to write to * @return the number of characters copied * @throws NullPointerException if the input or output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.3 + * @since 1.3 */ public static long copyLarge(Reader input, Writer output) throws IOException { - char[] buffer = new char[DEFAULT_BUFFER_SIZE]; + return copyLarge(input, output, new char[DEFAULT_BUFFER_SIZE]); + } + + /** + * Copy chars from a large (over 2GB) Reader to a Writer. + *

    + * This method uses the provided buffer, so there is no need to use a + * BufferedReader. + *

    + * + * @param input the Reader to read from + * @param output the Writer to write to + * @param buffer the buffer to be used for the copy + * @return the number of characters copied + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 2.2 + */ + public static long copyLarge(Reader input, Writer output, char [] buffer) throws IOException { long count = 0; int n = 0; - while (-1 != (n = input.read(buffer))) { + while (EOF != (n = input.read(buffer))) { output.write(buffer, 0, n); count += n; } return count; } /** + * Copy some or all chars from a large (over 2GB) InputStream to an + * OutputStream, optionally skipping input chars. + *

    + * This method buffers the input internally, so there is no need to use a + * BufferedReader. + *

    + * The buffer size is given by {@link #DEFAULT_BUFFER_SIZE}. + * + * @param input the Reader to read from + * @param output the Writer to write to + * @param inputOffset : number of chars to skip from input before copying + * -ve values are ignored + * @param length : number of chars to copy. -ve means all + * @return the number of chars copied + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 2.2 + */ + public static long copyLarge(Reader input, Writer output, final long inputOffset, final long length) + throws IOException { + return copyLarge(input, output, inputOffset, length, new char[DEFAULT_BUFFER_SIZE]); + } + + /** + * Copy some or all chars from a large (over 2GB) InputStream to an + * OutputStream, optionally skipping input chars. + *

    + * This method uses the provided buffer, so there is no need to use a + * BufferedReader. + *

    + * + * @param input the Reader to read from + * @param output the Writer to write to + * @param inputOffset : number of chars to skip from input before copying + * -ve values are ignored + * @param length : number of chars to copy. -ve means all + * @param buffer the buffer to be used for the copy + * @return the number of chars copied + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 2.2 + */ + public static long copyLarge(Reader input, Writer output, final long inputOffset, final long length, char [] buffer) + throws IOException { + if (inputOffset > 0) { + skipFully(input, inputOffset); + } + if (length == 0) { + return 0; + } + int bytesToRead = buffer.length; + if (length > 0 && length < buffer.length) { + bytesToRead = (int) length; + } + int read; + long totalRead = 0; + while (bytesToRead > 0 && EOF != (read = input.read(buffer, 0, bytesToRead))) { + output.write(buffer, 0, read); + totalRead += read; + if (length > 0) { // only adjust length if not reading to the end + // Note the cast must work because buffer.length is an integer + bytesToRead = (int) Math.min(length - totalRead, buffer.length); + } + } + return totalRead; + } + + /** * Copy chars from a Reader to bytes on an * OutputStream using the default character encoding of the * platform, and calling flush. @@ -1506,14 +2090,41 @@ * @param output the OutputStream to write to * @throws NullPointerException if the input or output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 */ public static void copy(Reader input, OutputStream output) throws IOException { - OutputStreamWriter out = new OutputStreamWriter(output); + copy(input, output, Charset.defaultCharset()); + } + + /** + * Copy chars from a Reader to bytes on an + * OutputStream using the specified character encoding, and + * calling flush. + *

    + * This method buffers the input internally, so there is no need to use a + * BufferedReader. + *

    + *

    + * Due to the implementation of OutputStreamWriter, this method performs a + * flush. + *

    + *

    + * This method uses {@link OutputStreamWriter}. + *

    + * + * @param input the Reader to read from + * @param output the OutputStream to write to + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static void copy(Reader input, OutputStream output, Charset encoding) throws IOException { + OutputStreamWriter out = new OutputStreamWriter(output, Charsets.toCharset(encoding)); copy(input, out); - // XXX Unless anyone is planning on rewriting OutputStreamWriter, we - // have to flush here. + // XXX Unless anyone is planning on rewriting OutputStreamWriter, + // we have to flush here. out.flush(); } @@ -1538,19 +2149,13 @@ * @param encoding the encoding to use, null means platform default * @throws NullPointerException if the input or output is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + * @since 1.1 */ - public static void copy(Reader input, OutputStream output, String encoding) - throws IOException { - if (encoding == null) { - copy(input, output); - } else { - OutputStreamWriter out = new OutputStreamWriter(output, encoding); - copy(input, out); - // XXX Unless anyone is planning on rewriting OutputStreamWriter, - // we have to flush here. - out.flush(); - } + public static void copy(Reader input, OutputStream output, String encoding) throws IOException { + copy(input, output, Charsets.toCharset(encoding)); } // content equals @@ -1579,7 +2184,7 @@ } int ch = input1.read(); - while (-1 != ch) { + while (EOF != ch) { int ch2 = input2.read(); if (ch != ch2) { return false; @@ -1588,7 +2193,7 @@ } int ch2 = input2.read(); - return (ch2 == -1); + return ch2 == EOF; } /** @@ -1604,19 +2209,16 @@ * exist, false otherwise * @throws NullPointerException if either input is null * @throws IOException if an I/O error occurs - * @since Commons IO 1.1 + * @since 1.1 */ public static boolean contentEquals(Reader input1, Reader input2) throws IOException { - if (!(input1 instanceof BufferedReader)) { - input1 = new BufferedReader(input1); - } - if (!(input2 instanceof BufferedReader)) { - input2 = new BufferedReader(input2); - } + + input1 = toBufferedReader(input1); + input2 = toBufferedReader(input2); int ch = input1.read(); - while (-1 != ch) { + while (EOF != ch) { int ch2 = input2.read(); if (ch != ch2) { return false; @@ -1625,10 +2227,38 @@ } int ch2 = input2.read(); - return (ch2 == -1); + return ch2 == EOF; } /** + * Compare the contents of two Readers to determine if they are equal or + * not, ignoring EOL characters. + *

    + * This method buffers the input internally using + * BufferedReader if they are not already buffered. + * + * @param input1 the first reader + * @param input2 the second reader + * @return true if the content of the readers are equal (ignoring EOL differences), false otherwise + * @throws NullPointerException if either input is null + * @throws IOException if an I/O error occurs + * @since 2.2 + */ + public static boolean contentEqualsIgnoreEOL(Reader input1, Reader input2) + throws IOException { + BufferedReader br1 = toBufferedReader(input1); + BufferedReader br2 = toBufferedReader(input2); + + String line1 = br1.readLine(); + String line2 = br2.readLine(); + while (line1 != null && line2 != null && line1.equals(line2)) { + line1 = br1.readLine(); + line2 = br2.readLine(); + } + return line1 == null ? line2 == null ? true : false : line1.equals(line2); + } + + /** * Skip bytes from an input byte stream. * This implementation guarantees that it will read as many bytes * as possible before giving up; this may not always be the case for @@ -1642,31 +2272,29 @@ * * @throws IOException if there is a problem reading the file * @throws IllegalArgumentException if toSkip is negative - * @since Commons IO 2.0 + * @since 2.0 */ public static long skip(InputStream input, long toSkip) throws IOException { if (toSkip < 0) { - throw new IllegalArgumentException("Skip count must be non-negative, actual: "+toSkip); + throw new IllegalArgumentException("Skip count must be non-negative, actual: " + toSkip); } /* - * N.B. no need to synchronize this because: - * - we don't care if the buffer is created multiple times (the data is ignored) - * - we always use the same size buffer, so if it it is recreated it will still be OK - * (if the buffer size were variable, we would need to synch. to ensure some other thread - * did not create a smaller one) + * N.B. no need to synchronize this because: - we don't care if the buffer is created multiple times (the data + * is ignored) - we always use the same size buffer, so if it it is recreated it will still be OK (if the buffer + * size were variable, we would need to synch. to ensure some other thread did not create a smaller one) */ - if (SKIP_BYTE_BUFFER == null){ + if (SKIP_BYTE_BUFFER == null) { SKIP_BYTE_BUFFER = new byte[SKIP_BUFFER_SIZE]; } - long remain=toSkip; - while(remain > 0) { + long remain = toSkip; + while (remain > 0) { long n = input.read(SKIP_BYTE_BUFFER, 0, (int) Math.min(remain, SKIP_BUFFER_SIZE)); if (n < 0) { // EOF break; } remain -= n; } - return toSkip - remain; + return toSkip - remain; } /** @@ -1683,31 +2311,29 @@ * * @throws IOException if there is a problem reading the file * @throws IllegalArgumentException if toSkip is negative - * @since Commons IO 2.0 + * @since 2.0 */ public static long skip(Reader input, long toSkip) throws IOException { if (toSkip < 0) { - throw new IllegalArgumentException("Skip count must be non-negative, actual: "+toSkip); + throw new IllegalArgumentException("Skip count must be non-negative, actual: " + toSkip); } /* - * N.B. no need to synchronize this because: - * - we don't care if the buffer is created multiple times (the data is ignored) - * - we always use the same size buffer, so if it it is recreated it will still be OK - * (if the buffer size were variable, we would need to synch. to ensure some other thread - * did not create a smaller one) + * N.B. no need to synchronize this because: - we don't care if the buffer is created multiple times (the data + * is ignored) - we always use the same size buffer, so if it it is recreated it will still be OK (if the buffer + * size were variable, we would need to synch. to ensure some other thread did not create a smaller one) */ - if (SKIP_CHAR_BUFFER == null){ + if (SKIP_CHAR_BUFFER == null) { SKIP_CHAR_BUFFER = new char[SKIP_BUFFER_SIZE]; } - long remain=toSkip; - while(remain > 0) { + long remain = toSkip; + while (remain > 0) { long n = input.read(SKIP_CHAR_BUFFER, 0, (int) Math.min(remain, SKIP_BUFFER_SIZE)); if (n < 0) { // EOF break; } remain -= n; } - return toSkip - remain; + return toSkip - remain; } /** @@ -1723,15 +2349,15 @@ * @throws IOException if there is a problem reading the file * @throws IllegalArgumentException if toSkip is negative * @throws EOFException if the number of bytes skipped was incorrect - * @since Commons IO 2.0 + * @since 2.0 */ public static void skipFully(InputStream input, long toSkip) throws IOException { - if (toSkip < 0){ - throw new IllegalArgumentException("Bytes to skip must not be negative: "+toSkip); + if (toSkip < 0) { + throw new IllegalArgumentException("Bytes to skip must not be negative: " + toSkip); } long skipped = skip(input, toSkip); if (skipped != toSkip) { - throw new EOFException("Bytes to skip: "+toSkip+" actual: "+skipped); + throw new EOFException("Bytes to skip: " + toSkip + " actual: " + skipped); } } @@ -1748,12 +2374,187 @@ * @throws IOException if there is a problem reading the file * @throws IllegalArgumentException if toSkip is negative * @throws EOFException if the number of characters skipped was incorrect - * @since Commons IO 2.0 + * @since 2.0 */ public static void skipFully(Reader input, long toSkip) throws IOException { long skipped = skip(input, toSkip); if (skipped != toSkip) { - throw new EOFException("Bytes to skip: "+toSkip+" actual: "+skipped); + throw new EOFException("Chars to skip: " + toSkip + " actual: " + skipped); } } + + + /** + * Read characters from an input character stream. + * This implementation guarantees that it will read as many characters + * as possible before giving up; this may not always be the case for + * subclasses of {@link Reader}. + * + * @param input where to read input from + * @param buffer destination + * @param offset inital offset into buffer + * @param length length to read, must be >= 0 + * @return actual length read; may be less than requested if EOF was reached + * @throws IOException if a read error occurs + * @since 2.2 + */ + public static int read(Reader input, char[] buffer, int offset, int length) throws IOException { + if (length < 0) { + throw new IllegalArgumentException("Length must not be negative: " + length); + } + int remaining = length; + while (remaining > 0) { + int location = length - remaining; + int count = input.read(buffer, offset + location, remaining); + if (EOF == count) { // EOF + break; + } + remaining -= count; + } + return length - remaining; + } + + /** + * Read characters from an input character stream. + * This implementation guarantees that it will read as many characters + * as possible before giving up; this may not always be the case for + * subclasses of {@link Reader}. + * + * @param input where to read input from + * @param buffer destination + * @return actual length read; may be less than requested if EOF was reached + * @throws IOException if a read error occurs + * @since 2.2 + */ + public static int read(Reader input, char[] buffer) throws IOException { + return read(input, buffer, 0, buffer.length); + } + + /** + * Read bytes from an input stream. + * This implementation guarantees that it will read as many bytes + * as possible before giving up; this may not always be the case for + * subclasses of {@link InputStream}. + * + * @param input where to read input from + * @param buffer destination + * @param offset inital offset into buffer + * @param length length to read, must be >= 0 + * @return actual length read; may be less than requested if EOF was reached + * @throws IOException if a read error occurs + * @since 2.2 + */ + public static int read(InputStream input, byte[] buffer, int offset, int length) throws IOException { + if (length < 0) { + throw new IllegalArgumentException("Length must not be negative: " + length); + } + int remaining = length; + while (remaining > 0) { + int location = length - remaining; + int count = input.read(buffer, offset + location, remaining); + if (EOF == count) { // EOF + break; + } + remaining -= count; + } + return length - remaining; + } + + /** + * Read bytes from an input stream. + * This implementation guarantees that it will read as many bytes + * as possible before giving up; this may not always be the case for + * subclasses of {@link InputStream}. + * + * @param input where to read input from + * @param buffer destination + * @return actual length read; may be less than requested if EOF was reached + * @throws IOException if a read error occurs + * @since 2.2 + */ + public static int read(InputStream input, byte[] buffer) throws IOException { + return read(input, buffer, 0, buffer.length); + } + + /** + * Read the requested number of characters or fail if there are not enough left. + *

    + * This allows for the possibility that {@link Reader#read(char[], int, int)} may + * not read as many characters as requested (most likely because of reaching EOF). + * + * @param input where to read input from + * @param buffer destination + * @param offset inital offset into buffer + * @param length length to read, must be >= 0 + * + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if length is negative + * @throws EOFException if the number of characters read was incorrect + * @since 2.2 + */ + public static void readFully(Reader input, char[] buffer, int offset, int length) throws IOException { + int actual = read(input, buffer, offset, length); + if (actual != length) { + throw new EOFException("Length to read: " + length + " actual: " + actual); + } + } + + /** + * Read the requested number of characters or fail if there are not enough left. + *

    + * This allows for the possibility that {@link Reader#read(char[], int, int)} may + * not read as many characters as requested (most likely because of reaching EOF). + * + * @param input where to read input from + * @param buffer destination + * + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if length is negative + * @throws EOFException if the number of characters read was incorrect + * @since 2.2 + */ + public static void readFully(Reader input, char[] buffer) throws IOException { + readFully(input, buffer, 0, buffer.length); + } + + /** + * Read the requested number of bytes or fail if there are not enough left. + *

    + * This allows for the possibility that {@link InputStream#read(byte[], int, int)} may + * not read as many bytes as requested (most likely because of reaching EOF). + * + * @param input where to read input from + * @param buffer destination + * @param offset inital offset into buffer + * @param length length to read, must be >= 0 + * + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if length is negative + * @throws EOFException if the number of bytes read was incorrect + * @since 2.2 + */ + public static void readFully(InputStream input, byte[] buffer, int offset, int length) throws IOException { + int actual = read(input, buffer, offset, length); + if (actual != length) { + throw new EOFException("Length to read: " + length + " actual: " + actual); + } + } + + /** + * Read the requested number of bytes or fail if there are not enough left. + *

    + * This allows for the possibility that {@link InputStream#read(byte[], int, int)} may + * not read as many bytes as requested (most likely because of reaching EOF). + * + * @param input where to read input from + * @param buffer destination + * + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if length is negative + * @throws EOFException if the number of bytes read was incorrect + * @since 2.2 + */ + public static void readFully(InputStream input, byte[] buffer) throws IOException { + readFully(input, buffer, 0, buffer.length); + } } Index: 3rdParty_sources/commons-io/org/apache/commons/io/LineIterator.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/LineIterator.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/LineIterator.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/LineIterator.java 1 Aug 2014 09:13:51 -0000 1.1.2.1 @@ -44,10 +44,8 @@ * } *

    * - * @author Stephen Colebourne - * @author Sandy McArthur * @version $Id$ - * @since Commons IO 1.2 + * @since 1.2 */ public class LineIterator implements Iterator { @@ -83,7 +81,7 @@ * If there is an IOException then {@link #close()} will * be called on this instance. * - * @return true if the Reader has more lines + * @return {@code true} if the Reader has more lines * @throws IllegalStateException if an IO exception occurs */ public boolean hasNext() { @@ -112,7 +110,7 @@ /** * Overridable method to validate each line that is returned. - * + * This implementation always returns true. * @param line the line that is to be validated * @return true if valid, false to remove from the iterator */ Index: 3rdParty_sources/commons-io/org/apache/commons/io/TaggedIOException.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/TaggedIOException.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/TaggedIOException.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/TaggedIOException.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -24,7 +24,7 @@ * wrapped exception. Both the tag and the original exception can be used * to determine further processing when this exception is caught. * - * @since Commons IO 2.0 + * @since 2.0 */ public class TaggedIOException extends IOExceptionWithCause { @@ -58,8 +58,8 @@ * * @param throwable The Throwable object to check * @param tag tag object - * @return true if the throwable has the specified tag, - * otherwise false + * @return {@code true} if the throwable has the specified tag, + * otherwise {@code false} */ public static boolean isTaggedWith(Throwable throwable, Object tag) { return tag != null Index: 3rdParty_sources/commons-io/org/apache/commons/io/ThreadMonitor.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/ThreadMonitor.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/ThreadMonitor.java 1 Oct 2012 13:03:03 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/ThreadMonitor.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -48,7 +48,7 @@ * * @param timeout The timout amount in milliseconds * or no timeout if the value is zero or less - * @return The monitor thread or null + * @return The monitor thread or {@code null} * if the timout amount is not greater than zero */ public static Thread start(long timeout) { @@ -61,7 +61,7 @@ * @param thread The thread The thread to monitor * @param timeout The timout amount in milliseconds * or no timeout if the value is zero or less - * @return The monitor thread or null + * @return The monitor thread or {@code null} * if the timout amount is not greater than zero */ public static Thread start(Thread thread, long timeout) { @@ -78,7 +78,7 @@ /** * Stop monitoring the specified thread. * - * @param thread The monitor thread, may be null + * @param thread The monitor thread, may be {@code null} */ public static void stop(Thread thread) { if (thread != null) { Index: 3rdParty_sources/commons-io/org/apache/commons/io/comparator/AbstractFileComparator.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/comparator/AbstractFileComparator.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/comparator/AbstractFileComparator.java 1 Oct 2012 13:02:59 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/comparator/AbstractFileComparator.java 1 Aug 2014 09:13:51 -0000 1.1.2.1 @@ -25,8 +25,8 @@ /** * Abstract file {@link Comparator} which provides sorting for file arrays and lists. * - * @version $Revision$ $Date$ - * @since Commons IO 2.0 + * @version $Id$ + * @since 2.0 */ abstract class AbstractFileComparator implements Comparator { @@ -38,7 +38,7 @@ * * @param files The files to sort, may be null * @return The sorted array - * @since Commons IO 2.0 + * @since 2.0 */ public File[] sort(File... files) { if (files != null) { @@ -55,7 +55,7 @@ * * @param files The files to sort, may be null * @return The sorted list - * @since Commons IO 2.0 + * @since 2.0 */ public List sort(List files) { if (files != null) { Index: 3rdParty_sources/commons-io/org/apache/commons/io/comparator/CompositeFileComparator.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/comparator/CompositeFileComparator.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/comparator/CompositeFileComparator.java 1 Oct 2012 13:02:59 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/comparator/CompositeFileComparator.java 1 Aug 2014 09:13:51 -0000 1.1.2.1 @@ -39,8 +39,8 @@ * comparator.sort(list); * * - * @version $Revision$ $Date$ - * @since Commons IO 2.0 + * @version $Id$ + * @since 2.0 */ public class CompositeFileComparator extends AbstractFileComparator implements Serializable { Index: 3rdParty_sources/commons-io/org/apache/commons/io/comparator/DefaultFileComparator.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/comparator/DefaultFileComparator.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/comparator/DefaultFileComparator.java 1 Oct 2012 13:02:59 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/comparator/DefaultFileComparator.java 1 Aug 2014 09:13:51 -0000 1.1.2.1 @@ -41,8 +41,8 @@ * *

    * - * @version $Revision$ $Date$ - * @since Commons IO 1.4 + * @version $Id$ + * @since 1.4 */ public class DefaultFileComparator extends AbstractFileComparator implements Serializable { Index: 3rdParty_sources/commons-io/org/apache/commons/io/comparator/DirectoryFileComparator.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/comparator/DirectoryFileComparator.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/comparator/DirectoryFileComparator.java 1 Oct 2012 13:02:58 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/comparator/DirectoryFileComparator.java 1 Aug 2014 09:13:51 -0000 1.1.2.1 @@ -40,8 +40,8 @@ * *

    * - * @version $Revision$ $Date$ - * @since Commons IO 2.0 + * @version $Id$ + * @since 2.0 */ public class DirectoryFileComparator extends AbstractFileComparator implements Serializable { @@ -60,7 +60,7 @@ * {@link File#compareTo(File)} with file2 as the parameter. */ public int compare(File file1, File file2) { - return (getType(file1) - getType(file2)); + return getType(file1) - getType(file2); } /** Index: 3rdParty_sources/commons-io/org/apache/commons/io/comparator/ExtensionFileComparator.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/comparator/ExtensionFileComparator.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/comparator/ExtensionFileComparator.java 1 Oct 2012 13:02:59 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/comparator/ExtensionFileComparator.java 1 Aug 2014 09:13:51 -0000 1.1.2.1 @@ -48,8 +48,8 @@ * *

    * - * @version $Revision$ $Date$ - * @since Commons IO 1.4 + * @version $Id$ + * @since 1.4 */ public class ExtensionFileComparator extends AbstractFileComparator implements Serializable { Index: 3rdParty_sources/commons-io/org/apache/commons/io/comparator/LastModifiedFileComparator.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/comparator/LastModifiedFileComparator.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/comparator/LastModifiedFileComparator.java 1 Oct 2012 13:02:59 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/comparator/LastModifiedFileComparator.java 1 Aug 2014 09:13:51 -0000 1.1.2.1 @@ -42,8 +42,8 @@ * *

    * - * @version $Revision$ $Date$ - * @since Commons IO 1.4 + * @version $Id$ + * @since 1.4 */ public class LastModifiedFileComparator extends AbstractFileComparator implements Serializable { Index: 3rdParty_sources/commons-io/org/apache/commons/io/comparator/NameFileComparator.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/comparator/NameFileComparator.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/comparator/NameFileComparator.java 1 Oct 2012 13:02:59 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/comparator/NameFileComparator.java 1 Aug 2014 09:13:51 -0000 1.1.2.1 @@ -46,8 +46,8 @@ * *

    * - * @version $Revision$ $Date$ - * @since Commons IO 1.4 + * @version $Id$ + * @since 1.4 */ public class NameFileComparator extends AbstractFileComparator implements Serializable { Index: 3rdParty_sources/commons-io/org/apache/commons/io/comparator/PathFileComparator.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/comparator/PathFileComparator.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/comparator/PathFileComparator.java 1 Oct 2012 13:02:59 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/comparator/PathFileComparator.java 1 Aug 2014 09:13:51 -0000 1.1.2.1 @@ -46,8 +46,8 @@ * *

    * - * @version $Revision$ $Date$ - * @since Commons IO 1.4 + * @version $Id$ + * @since 1.4 */ public class PathFileComparator extends AbstractFileComparator implements Serializable { Index: 3rdParty_sources/commons-io/org/apache/commons/io/comparator/ReverseComparator.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/comparator/ReverseComparator.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/comparator/ReverseComparator.java 1 Oct 2012 13:02:58 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/comparator/ReverseComparator.java 1 Aug 2014 09:13:51 -0000 1.1.2.1 @@ -24,8 +24,8 @@ * Reverses the result of comparing two objects using * the delegate {@link Comparator}. * - * @version $Revision$ $Date$ - * @since Commons IO 1.4 + * @version $Id$ + * @since 1.4 */ class ReverseComparator extends AbstractFileComparator implements Serializable { Index: 3rdParty_sources/commons-io/org/apache/commons/io/comparator/SizeFileComparator.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/comparator/SizeFileComparator.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/comparator/SizeFileComparator.java 1 Oct 2012 13:02:59 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/comparator/SizeFileComparator.java 1 Aug 2014 09:13:51 -0000 1.1.2.1 @@ -44,10 +44,10 @@ * *

    * N.B. Directories are treated as zero size unless - * sumDirectoryContents is true. + * sumDirectoryContents is {@code true}. * - * @version $Revision$ $Date$ - * @since Commons IO 1.4 + * @version $Id$ + * @since 1.4 */ public class SizeFileComparator extends AbstractFileComparator implements Serializable { @@ -83,11 +83,11 @@ * Construct a file size comparator instance specifying whether the size of * the directory contents should be aggregated. *

    - * If the sumDirectoryContents is true The size of + * If the sumDirectoryContents is {@code true} The size of * directories is calculated using {@link FileUtils#sizeOfDirectory(File)}. * - * @param sumDirectoryContents true if the sum of the directoryies contents - * should be calculated, otherwise false if directories should be treated + * @param sumDirectoryContents {@code true} if the sum of the directoryies contents + * should be calculated, otherwise {@code false} if directories should be treated * as size zero (see {@link FileUtils#sizeOfDirectory(File)}). */ public SizeFileComparator(boolean sumDirectoryContents) { Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/AbstractFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/AbstractFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/AbstractFileFilter.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/AbstractFileFilter.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -25,10 +25,8 @@ * Note that a subclass must override one of the accept methods, * otherwise your class will infinitely loop. * - * @since Commons IO 1.0 - * @version $Revision$ $Date$ - * - * @author Stephen Colebourne + * @since 1.0 + * @version $Id$ */ public abstract class AbstractFileFilter implements IOFileFilter { Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/AgeFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/AgeFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/AgeFileFilter.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/AgeFileFilter.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -39,15 +39,14 @@ * } * * - * @author Rahul Akolkar * @version $Id$ * @see FileFilterUtils#ageFileFilter(Date) * @see FileFilterUtils#ageFileFilter(File) * @see FileFilterUtils#ageFileFilter(long) * @see FileFilterUtils#ageFileFilter(Date, boolean) * @see FileFilterUtils#ageFileFilter(File, boolean) * @see FileFilterUtils#ageFileFilter(long, boolean) - * @since Commons IO 1.2 + * @since 1.2 */ public class AgeFileFilter extends AbstractFileFilter implements Serializable { Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/AndFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/AndFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/AndFileFilter.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/AndFileFilter.java 1 Aug 2014 09:13:47 -0000 1.1.2.1 @@ -24,15 +24,14 @@ /** * A {@link java.io.FileFilter} providing conditional AND logic across a list of - * file filters. This filter returns true if all filters in the - * list return true. Otherwise, it returns false. + * file filters. This filter returns {@code true} if all filters in the + * list return {@code true}. Otherwise, it returns {@code false}. * Checking of the file filter list stops when the first filter returns - * false. + * {@code false}. * - * @since Commons IO 1.0 - * @version $Revision$ $Date$ + * @since 1.0 + * @version $Id$ * - * @author Steven Caswell * @see FileFilterUtils#and(IOFileFilter...) */ public class AndFileFilter @@ -45,7 +44,7 @@ /** * Constructs a new instance of AndFileFilter. * - * @since Commons IO 1.1 + * @since 1.1 */ public AndFileFilter() { this.fileFilters = new ArrayList(); @@ -56,7 +55,7 @@ * with the specified list of filters. * * @param fileFilters a List of IOFileFilter instances, copied, null ignored - * @since Commons IO 1.1 + * @since 1.1 */ public AndFileFilter(final List fileFilters) { if (fileFilters == null) { @@ -116,7 +115,7 @@ */ @Override public boolean accept(final File file) { - if (this.fileFilters.size() == 0) { + if (this.fileFilters.isEmpty()) { return false; } for (IOFileFilter fileFilter : fileFilters) { @@ -132,7 +131,7 @@ */ @Override public boolean accept(final File file, final String name) { - if (this.fileFilters.size() == 0) { + if (this.fileFilters.isEmpty()) { return false; } for (IOFileFilter fileFilter : fileFilters) { Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/CanReadFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/CanReadFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/CanReadFileFilter.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/CanReadFileFilter.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -57,8 +57,8 @@ * } * * - * @since Commons IO 1.3 - * @version $Revision$ + * @since 1.3 + * @version $Id$ */ public class CanReadFileFilter extends AbstractFileFilter implements Serializable { @@ -82,8 +82,8 @@ * Checks to see if the file can be read. * * @param file the File to check. - * @return true if the file can be - * read, otherwise false. + * @return {@code true} if the file can be + * read, otherwise {@code false}. */ @Override public boolean accept(File file) { Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/CanWriteFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/CanWriteFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/CanWriteFileFilter.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/CanWriteFileFilter.java 1 Aug 2014 09:13:47 -0000 1.1.2.1 @@ -49,8 +49,8 @@ * N.B. For read-only files, use * CanReadFileFilter.READ_ONLY. * - * @since Commons IO 1.3 - * @version $Revision$ + * @since 1.3 + * @version $Id$ */ public class CanWriteFileFilter extends AbstractFileFilter implements Serializable { @@ -70,8 +70,8 @@ * Checks to see if the file can be written to. * * @param file the File to check - * @return true if the file can be - * written to, otherwise false. + * @return {@code true} if the file can be + * written to, otherwise {@code false}. */ @Override public boolean accept(File file) { Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/ConditionalFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/ConditionalFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/ConditionalFileFilter.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/ConditionalFileFilter.java 1 Aug 2014 09:13:47 -0000 1.1.2.1 @@ -21,10 +21,8 @@ /** * Defines operations for conditional file filters. * - * @since Commons IO 1.1 - * @version $Revision$ $Date$ - * - * @author Steven Caswell + * @since 1.1 + * @version $Id$ */ public interface ConditionalFileFilter { @@ -33,25 +31,25 @@ * the list. * * @param ioFileFilter the filter to be added - * @since Commons IO 1.1 + * @since 1.1 */ void addFileFilter(IOFileFilter ioFileFilter); /** * Returns this conditional file filter's list of file filters. * * @return the file filter list - * @since Commons IO 1.1 + * @since 1.1 */ List getFileFilters(); /** * Removes the specified file filter. * * @param ioFileFilter filter to be removed - * @return true if the filter was found in the list, - * false otherwise - * @since Commons IO 1.1 + * @return {@code true} if the filter was found in the list, + * {@code false} otherwise + * @since 1.1 */ boolean removeFileFilter(IOFileFilter ioFileFilter); @@ -60,7 +58,7 @@ * file filters on this filter. * * @param fileFilters the list of filters - * @since Commons IO 1.1 + * @since 1.1 */ void setFileFilters(List fileFilters); Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/DelegateFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/DelegateFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/DelegateFileFilter.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/DelegateFileFilter.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -24,10 +24,9 @@ /** * This class turns a Java FileFilter or FilenameFilter into an IO FileFilter. * - * @since Commons IO 1.0 - * @version $Revision$ $Date$ + * @since 1.0 + * @version $Id$ * - * @author Stephen Colebourne * @see FileFilterUtils#asFileFilter(FileFilter) * @see FileFilterUtils#asFileFilter(FilenameFilter) */ @@ -102,7 +101,7 @@ */ @Override public String toString() { - String delegate = (fileFilter != null ? fileFilter.toString() : filenameFilter.toString()); + String delegate = fileFilter != null ? fileFilter.toString() : filenameFilter.toString(); return super.toString() + "(" + delegate + ")"; } Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/DirectoryFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/DirectoryFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/DirectoryFileFilter.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/DirectoryFileFilter.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -33,18 +33,16 @@ * } * * - * @since Commons IO 1.0 - * @version $Revision$ $Date$ + * @since 1.0 + * @version $Id$ * - * @author Stephen Colebourne - * @author Peter Donald * @see FileFilterUtils#directoryFileFilter() */ public class DirectoryFileFilter extends AbstractFileFilter implements Serializable { /** * Singleton instance of directory filter. - * @since Commons IO 1.3 + * @since 1.3 */ public static final IOFileFilter DIRECTORY = new DirectoryFileFilter(); /** Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/EmptyFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/EmptyFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/EmptyFileFilter.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/EmptyFileFilter.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -48,8 +48,8 @@ * } * * - * @since Commons IO 1.3 - * @version $Revision$ + * @since 1.3 + * @version $Id$ */ public class EmptyFileFilter extends AbstractFileFilter implements Serializable { @@ -69,16 +69,16 @@ * Checks to see if the file is empty. * * @param file the file or directory to check - * @return true if the file or directory - * is empty, otherwise false. + * @return {@code true} if the file or directory + * is empty, otherwise {@code false}. */ @Override public boolean accept(File file) { if (file.isDirectory()) { File[] files = file.listFiles(); - return (files == null || files.length == 0); + return files == null || files.length == 0; } else { - return (file.length() == 0); + return file.length() == 0; } } Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/FalseFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/FalseFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/FalseFileFilter.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/FalseFileFilter.java 1 Aug 2014 09:13:47 -0000 1.1.2.1 @@ -22,17 +22,16 @@ /** * A file filter that always returns false. * - * @since Commons IO 1.0 - * @version $Revision$ $Date$ + * @since 1.0 + * @version $Id$ * - * @author Stephen Colebourne * @see FileFilterUtils#falseFileFilter() */ public class FalseFileFilter implements IOFileFilter, Serializable { /** * Singleton instance of false filter. - * @since Commons IO 1.3 + * @since 1.3 */ public static final IOFileFilter FALSE = new FalseFileFilter(); /** @@ -52,7 +51,7 @@ /** * Returns false. * - * @param file the file to check + * @param file the file to check (ignored) * @return false */ public boolean accept(File file) { @@ -62,8 +61,8 @@ /** * Returns false. * - * @param dir the directory to check - * @param name the filename + * @param dir the directory to check (ignored) + * @param name the filename (ignored) * @return false */ public boolean accept(File dir, String name) { Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/FileFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/FileFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/FileFileFilter.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/FileFileFilter.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -33,8 +33,8 @@ * } * * - * @since Commons IO 1.3 - * @version $Revision$ $Date$ + * @since 1.3 + * @version $Id$ * @see FileFilterUtils#fileFileFilter() */ public class FileFileFilter extends AbstractFileFilter implements Serializable { Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/FileFilterUtils.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/FileFilterUtils.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/FileFilterUtils.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/FileFilterUtils.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -34,13 +34,8 @@ * file filter implementations in this package so you don't have to import * every class you use. * - * @since Commons IO 1.0 + * @since 1.0 * @version $Id$ - * - * @author Stephen Colebourne - * @author Jeremias Maerki - * @author Masato Tezuka - * @author Rahul Akolkar */ public class FileFilterUtils { @@ -73,10 +68,10 @@ * * @return a subset of files that is accepted by the * file filter. - * @throws IllegalArgumentException if the filter is null - * or files contains a null value. + * @throws IllegalArgumentException if the filter is {@code null} + * or files contains a {@code null} value. * - * @since Commons IO 2.0 + * @since 2.0 */ public static File[] filter(IOFileFilter filter, File... files) { if (filter == null) { @@ -118,10 +113,10 @@ * * @return a subset of files that is accepted by the * file filter. - * @throws IllegalArgumentException if the filter is null - * or files contains a null value. + * @throws IllegalArgumentException if the filter is {@code null} + * or files contains a {@code null} value. * - * @since Commons IO 2.0 + * @since 2.0 */ public static File[] filter(IOFileFilter filter, Iterable files) { List acceptedFiles = filterList(filter, files); @@ -149,9 +144,9 @@ * * @return a subset of files that is accepted by the * file filter. - * @throws IllegalArgumentException if the filter is null - * or files contains a null value. - * @since Commons IO 2.0 + * @throws IllegalArgumentException if the filter is {@code null} + * or files contains a {@code null} value. + * @since 2.0 */ public static List filterList(IOFileFilter filter, Iterable files) { return filter(filter, files, new ArrayList()); @@ -178,9 +173,9 @@ * * @return a subset of files that is accepted by the * file filter. - * @throws IllegalArgumentException if the filter is null - * or files contains a null value. - * @since Commons IO 2.0 + * @throws IllegalArgumentException if the filter is {@code null} + * or files contains a {@code null} value. + * @since 2.0 */ public static List filterList(IOFileFilter filter, File... files) { File[] acceptedFiles = filter(filter, files); @@ -208,10 +203,10 @@ * * @return a subset of files that is accepted by the * file filter. - * @throws IllegalArgumentException if the filter is null - * or files contains a null value. + * @throws IllegalArgumentException if the filter is {@code null} + * or files contains a {@code null} value. * - * @since Commons IO 2.0 + * @since 2.0 */ public static Set filterSet(IOFileFilter filter, File... files) { File[] acceptedFiles = filter(filter, files); @@ -239,10 +234,10 @@ * * @return a subset of files that is accepted by the * file filter. - * @throws IllegalArgumentException if the filter is null - * or files contains a null value. + * @throws IllegalArgumentException if the filter is {@code null} + * or files contains a {@code null} value. * - * @since Commons IO 2.0 + * @since 2.0 */ public static Set filterSet(IOFileFilter filter, Iterable files) { return filter(filter, files, new HashSet()); @@ -267,8 +262,8 @@ * @param the type of the file collection. * @return a subset of files that is accepted by the * file filter. - * @throws IllegalArgumentException if the filter is null - * or files contains a null value. + * @throws IllegalArgumentException if the filter is {@code null} + * or files contains a {@code null} value. */ private static > T filter(IOFileFilter filter, Iterable files, T acceptedFiles) { @@ -306,7 +301,7 @@ * @param caseSensitivity how to handle case sensitivity, null means case-sensitive * @return a prefix checking filter * @see PrefixFileFilter - * @since Commons IO 2.0 + * @since 2.0 */ public static IOFileFilter prefixFileFilter(String prefix, IOCase caseSensitivity) { return new PrefixFileFilter(prefix, caseSensitivity); @@ -330,7 +325,7 @@ * @param caseSensitivity how to handle case sensitivity, null means case-sensitive * @return a suffix checking filter * @see SuffixFileFilter - * @since Commons IO 2.0 + * @since 2.0 */ public static IOFileFilter suffixFileFilter(String suffix, IOCase caseSensitivity) { return new SuffixFileFilter(suffix, caseSensitivity); @@ -354,7 +349,7 @@ * @param caseSensitivity how to handle case sensitivity, null means case-sensitive * @return a name checking filter * @see NameFileFilter - * @since Commons IO 2.0 + * @since 2.0 */ public static IOFileFilter nameFileFilter(String name, IOCase caseSensitivity) { return new NameFileFilter(name, caseSensitivity); @@ -420,7 +415,7 @@ * @throws IllegalArgumentException if the filters are null or contain a * null value. * @see AndFileFilter - * @since Commons IO 2.0 + * @since 2.0 */ public static IOFileFilter and(IOFileFilter... filters) { return new AndFileFilter(toList(filters)); @@ -435,7 +430,7 @@ * @throws IllegalArgumentException if the filters are null or contain a * null value. * @see OrFileFilter - * @since Commons IO 2.0 + * @since 2.0 */ public static IOFileFilter or(IOFileFilter... filters) { return new OrFileFilter(toList(filters)); @@ -448,7 +443,7 @@ * @return The list of file filters * @throws IllegalArgumentException if the filters are null or contain a * null value. - * @since Commons IO 2.0 + * @since 2.0 */ public static List toList(IOFileFilter... filters) { if (filters == null) { @@ -529,7 +524,7 @@ * @param cutoff the time threshold * @return an appropriately configured age file filter * @see AgeFileFilter - * @since Commons IO 1.2 + * @since 1.2 */ public static IOFileFilter ageFileFilter(long cutoff) { return new AgeFileFilter(cutoff); @@ -542,7 +537,7 @@ * @param acceptOlder if true, older files get accepted, if false, newer * @return an appropriately configured age file filter * @see AgeFileFilter - * @since Commons IO 1.2 + * @since 1.2 */ public static IOFileFilter ageFileFilter(long cutoff, boolean acceptOlder) { return new AgeFileFilter(cutoff, acceptOlder); @@ -555,7 +550,7 @@ * @param cutoffDate the time threshold * @return an appropriately configured age file filter * @see AgeFileFilter - * @since Commons IO 1.2 + * @since 1.2 */ public static IOFileFilter ageFileFilter(Date cutoffDate) { return new AgeFileFilter(cutoffDate); @@ -568,7 +563,7 @@ * @param acceptOlder if true, older files get accepted, if false, newer * @return an appropriately configured age file filter * @see AgeFileFilter - * @since Commons IO 1.2 + * @since 1.2 */ public static IOFileFilter ageFileFilter(Date cutoffDate, boolean acceptOlder) { return new AgeFileFilter(cutoffDate, acceptOlder); @@ -582,7 +577,7 @@ * time is usesd as the threshold age of the files * @return an appropriately configured age file filter * @see AgeFileFilter - * @since Commons IO 1.2 + * @since 1.2 */ public static IOFileFilter ageFileFilter(File cutoffReference) { return new AgeFileFilter(cutoffReference); @@ -596,7 +591,7 @@ * @param acceptOlder if true, older files get accepted, if false, newer * @return an appropriately configured age file filter * @see AgeFileFilter - * @since Commons IO 1.2 + * @since 1.2 */ public static IOFileFilter ageFileFilter(File cutoffReference, boolean acceptOlder) { return new AgeFileFilter(cutoffReference, acceptOlder); @@ -609,7 +604,7 @@ * @param threshold the file size threshold * @return an appropriately configured SizeFileFilter * @see SizeFileFilter - * @since Commons IO 1.2 + * @since 1.2 */ public static IOFileFilter sizeFileFilter(long threshold) { return new SizeFileFilter(threshold); @@ -622,7 +617,7 @@ * @param acceptLarger if true, larger files get accepted, if false, smaller * @return an appropriately configured SizeFileFilter * @see SizeFileFilter - * @since Commons IO 1.2 + * @since 1.2 */ public static IOFileFilter sizeFileFilter(long threshold, boolean acceptLarger) { return new SizeFileFilter(threshold, acceptLarger); @@ -636,7 +631,7 @@ * @param maxSizeInclusive the maximum file size (inclusive) * @return an appropriately configured IOFileFilter * @see SizeFileFilter - * @since Commons IO 1.3 + * @since 1.3 */ public static IOFileFilter sizeRangeFileFilter(long minSizeInclusive, long maxSizeInclusive ) { IOFileFilter minimumFilter = new SizeFileFilter(minSizeInclusive, true); @@ -655,9 +650,9 @@ * magic number. * * @throws IllegalArgumentException if magicNumber is - * null or the empty String. + * {@code null} or the empty String. * @see MagicNumberFileFilter - * @since Commons IO 2.0 + * @since 2.0 */ public static IOFileFilter magicNumberFileFilter(String magicNumber) { return new MagicNumberFileFilter(magicNumber); @@ -675,10 +670,10 @@ * at the specified offset. * * @throws IllegalArgumentException if magicNumber is - * null or the empty String, or if offset is a + * {@code null} or the empty String, or if offset is a * negative number. * @see MagicNumberFileFilter - * @since Commons IO 2.0 + * @since 2.0 */ public static IOFileFilter magicNumberFileFilter(String magicNumber, long offset) { return new MagicNumberFileFilter(magicNumber, offset); @@ -695,9 +690,9 @@ * magic number. * * @throws IllegalArgumentException if magicNumber is - * null or is of length zero. + * {@code null} or is of length zero. * @see MagicNumberFileFilter - * @since Commons IO 2.0 + * @since 2.0 */ public static IOFileFilter magicNumberFileFilter(byte[] magicNumber) { return new MagicNumberFileFilter(magicNumber); @@ -715,10 +710,10 @@ * at the specified offset. * * @throws IllegalArgumentException if magicNumber is - * null, or contains no bytes, or offset + * {@code null}, or contains no bytes, or offset * is a negative number. * @see MagicNumberFileFilter - * @since Commons IO 2.0 + * @since 2.0 */ public static IOFileFilter magicNumberFileFilter(byte[] magicNumber, long offset) { return new MagicNumberFileFilter(magicNumber, offset); @@ -735,12 +730,12 @@ /** * Decorates a filter to make it ignore CVS directories. - * Passing in null will return a filter that accepts everything + * Passing in {@code null} will return a filter that accepts everything * except CVS directories. * * @param filter the filter to decorate, null means an unrestricted filter * @return the decorated filter, never null - * @since Commons IO 1.1 (method existed but had bug in 1.0) + * @since 1.1 (method existed but had bug in 1.0) */ public static IOFileFilter makeCVSAware(IOFileFilter filter) { if (filter == null) { @@ -752,12 +747,12 @@ /** * Decorates a filter to make it ignore SVN directories. - * Passing in null will return a filter that accepts everything + * Passing in {@code null} will return a filter that accepts everything * except SVN directories. * * @param filter the filter to decorate, null means an unrestricted filter * @return the decorated filter, never null - * @since Commons IO 1.1 + * @since 1.1 */ public static IOFileFilter makeSVNAware(IOFileFilter filter) { if (filter == null) { @@ -774,7 +769,7 @@ * @param filter the filter to decorate, null means an unrestricted filter * @return the decorated filter, never null * @see DirectoryFileFilter#DIRECTORY - * @since Commons IO 1.3 + * @since 1.3 */ public static IOFileFilter makeDirectoryOnly(IOFileFilter filter) { if (filter == null) { @@ -789,7 +784,7 @@ * @param filter the filter to decorate, null means an unrestricted filter * @return the decorated filter, never null * @see FileFileFilter#FILE - * @since Commons IO 1.3 + * @since 1.3 */ public static IOFileFilter makeFileOnly(IOFileFilter filter) { if (filter == null) { Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/HiddenFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/HiddenFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/HiddenFileFilter.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/HiddenFileFilter.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -45,8 +45,8 @@ * } * * - * @since Commons IO 1.3 - * @version $Revision$ + * @since 1.3 + * @version $Id$ */ public class HiddenFileFilter extends AbstractFileFilter implements Serializable { @@ -66,8 +66,8 @@ * Checks to see if the file is hidden. * * @param file the File to check - * @return true if the file is - * hidden, otherwise false. + * @return {@code true} if the file is + * hidden, otherwise {@code false}. */ @Override public boolean accept(File file) { Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/IOFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/IOFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/IOFileFilter.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/IOFileFilter.java 1 Aug 2014 09:13:47 -0000 1.1.2.1 @@ -24,10 +24,8 @@ * An interface which brings the FileFilter and FilenameFilter * interfaces together. * - * @since Commons IO 1.0 - * @version $Revision$ $Date$ - * - * @author Stephen Colebourne + * @since 1.0 + * @version $Id$ */ public interface IOFileFilter extends FileFilter, FilenameFilter { Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/MagicNumberFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/MagicNumberFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/MagicNumberFileFilter.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/MagicNumberFileFilter.java 1 Aug 2014 09:13:47 -0000 1.1.2.1 @@ -58,7 +58,7 @@ * System.out.println(tarFile); * } * - * @since Commons IO 2.0 + * @since 2.0 * @see FileFilterUtils#magicNumberFileFilter(byte[]) * @see FileFilterUtils#magicNumberFileFilter(String) * @see FileFilterUtils#magicNumberFileFilter(byte[], long) @@ -106,7 +106,7 @@ * @param magicNumber the magic number to look for in the file. * * @throws IllegalArgumentException if magicNumber is - * null, or contains no bytes. + * {@code null}, or contains no bytes. */ public MagicNumberFileFilter(byte[] magicNumber) { this(magicNumber, 0); @@ -131,7 +131,7 @@ * The string is converted to bytes using the platform default charset. * * @throws IllegalArgumentException if magicNumber is - * null or the empty String. + * {@code null} or the empty String. */ public MagicNumberFileFilter(String magicNumber) { this(magicNumber, 0); @@ -154,7 +154,7 @@ * @param offset the byte offset in the file to start comparing bytes. * * @throws IllegalArgumentException if magicNumber is - * null or the empty String, or offset is + * {@code null} or the empty String, or offset is * a negative number. */ public MagicNumberFileFilter(String magicNumber, long offset) { @@ -199,7 +199,7 @@ * @param offset the byte offset in the file to start comparing bytes. * * @throws IllegalArgumentException if magicNumber is - * null, or contains no bytes, or offset + * {@code null}, or contains no bytes, or offset * is a negative number. */ public MagicNumberFileFilter(byte[] magicNumber, long offset) { @@ -231,8 +231,8 @@ * * @param file the file to accept or reject. * - * @return true if the file contains the filter's magic number - * at the specified offset, false otherwise. + * @return {@code true} if the file contains the filter's magic number + * at the specified offset, {@code false} otherwise. */ @Override public boolean accept(File file) { Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/NameFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/NameFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/NameFileFilter.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/NameFileFilter.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -36,13 +36,8 @@ * } * * - * @since Commons IO 1.0 - * @version $Revision$ $Date$ - * - * @author Stephen Colebourne - * @author Federico Barbieri - * @author Serge Knystautas - * @author Peter Donald + * @since 1.0 + * @version $Id$ * @see FileFilterUtils#nameFileFilter(String) * @see FileFilterUtils#nameFileFilter(String, IOCase) */ @@ -75,7 +70,7 @@ throw new IllegalArgumentException("The wildcard must not be null"); } this.names = new String[] {name}; - this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; } /** @@ -107,7 +102,7 @@ } this.names = new String[names.length]; System.arraycopy(names, 0, this.names, 0, names.length); - this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; } /** @@ -134,7 +129,7 @@ throw new IllegalArgumentException("The list of names must not be null"); } this.names = names.toArray(new String[names.size()]); - this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; } //----------------------------------------------------------------------- @@ -158,12 +153,12 @@ /** * Checks to see if the filename matches. * - * @param file the File directory + * @param dir the File directory (ignored) * @param name the filename * @return true if the filename matches */ @Override - public boolean accept(File file, String name) { + public boolean accept(File dir, String name) { for (String name2 : names) { if (caseSensitivity.checkEquals(name, name2)) { return true; Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/NotFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/NotFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/NotFileFilter.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/NotFileFilter.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -22,10 +22,8 @@ /** * This filter produces a logical NOT of the filters specified. * - * @since Commons IO 1.0 - * @version $Revision$ $Date$ - * - * @author Stephen Colebourne + * @since 1.0 + * @version $Id$ * @see FileFilterUtils#notFileFilter(IOFileFilter) */ public class NotFileFilter extends AbstractFileFilter implements Serializable { Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/OrFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/OrFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/OrFileFilter.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/OrFileFilter.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -24,15 +24,13 @@ /** * A {@link java.io.FileFilter} providing conditional OR logic across a list of - * file filters. This filter returns true if any filters in the - * list return true. Otherwise, it returns false. + * file filters. This filter returns {@code true} if any filters in the + * list return {@code true}. Otherwise, it returns {@code false}. * Checking of the file filter list stops when the first filter returns - * true. + * {@code true}. * - * @since Commons IO 1.0 - * @version $Revision$ $Date$ - * - * @author Steven Caswell + * @since 1.0 + * @version $Id$ * @see FileFilterUtils#or(IOFileFilter...) */ public class OrFileFilter @@ -45,7 +43,7 @@ /** * Constructs a new instance of OrFileFilter. * - * @since Commons IO 1.1 + * @since 1.1 */ public OrFileFilter() { this.fileFilters = new ArrayList(); @@ -56,7 +54,7 @@ * with the specified filters. * * @param fileFilters the file filters for this filter, copied, null ignored - * @since Commons IO 1.1 + * @since 1.1 */ public OrFileFilter(final List fileFilters) { if (fileFilters == null) { Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/PrefixFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/PrefixFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/PrefixFileFilter.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/PrefixFileFilter.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -36,13 +36,8 @@ * } * * - * @since Commons IO 1.0 - * @version $Revision$ $Date$ - * - * @author Stephen Colebourne - * @author Federico Barbieri - * @author Serge Knystautas - * @author Peter Donald + * @since 1.0 + * @version $Id$ * @see FileFilterUtils#prefixFileFilter(String) * @see FileFilterUtils#prefixFileFilter(String, IOCase) */ @@ -71,14 +66,14 @@ * @param prefix the prefix to allow, must not be null * @param caseSensitivity how to handle case sensitivity, null means case-sensitive * @throws IllegalArgumentException if the prefix is null - * @since Commons IO 1.4 + * @since 1.4 */ public PrefixFileFilter(String prefix, IOCase caseSensitivity) { if (prefix == null) { throw new IllegalArgumentException("The prefix must not be null"); } this.prefixes = new String[] {prefix}; - this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; } /** @@ -104,15 +99,15 @@ * @param prefixes the prefixes to allow, must not be null * @param caseSensitivity how to handle case sensitivity, null means case-sensitive * @throws IllegalArgumentException if the prefix is null - * @since Commons IO 1.4 + * @since 1.4 */ public PrefixFileFilter(String[] prefixes, IOCase caseSensitivity) { if (prefixes == null) { throw new IllegalArgumentException("The array of prefixes must not be null"); } this.prefixes = new String[prefixes.length]; System.arraycopy(prefixes, 0, this.prefixes, 0, prefixes.length); - this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; } /** @@ -134,14 +129,14 @@ * @param caseSensitivity how to handle case sensitivity, null means case-sensitive * @throws IllegalArgumentException if the prefix list is null * @throws ClassCastException if the list does not contain Strings - * @since Commons IO 1.4 + * @since 1.4 */ public PrefixFileFilter(List prefixes, IOCase caseSensitivity) { if (prefixes == null) { throw new IllegalArgumentException("The list of prefixes must not be null"); } this.prefixes = prefixes.toArray(new String[prefixes.size()]); - this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; } /** Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/RegexFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/RegexFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/RegexFileFilter.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/RegexFileFilter.java 1 Aug 2014 09:13:47 -0000 1.1.2.1 @@ -39,9 +39,8 @@ * } * * - * @author Oliver Siegmar - * @version $Revision$ - * @since Commons IO 1.4 + * @version $Id$ + * @since 1.4 */ public class RegexFileFilter extends AbstractFileFilter implements Serializable { @@ -111,13 +110,13 @@ /** * Checks to see if the filename matches one of the regular expressions. * - * @param dir the file directory + * @param dir the file directory (ignored) * @param name the filename * @return true if the filename matches one of the regular expressions */ @Override public boolean accept(File dir, String name) { - return (pattern.matcher(name).matches()); + return pattern.matcher(name).matches(); } } Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/SizeFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/SizeFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/SizeFileFilter.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/SizeFileFilter.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -34,9 +34,8 @@ * } * * - * @author Rahul Akolkar * @version $Id$ - * @since Commons IO 1.2 + * @since 1.2 * @see FileFilterUtils#sizeFileFilter(long) * @see FileFilterUtils#sizeFileFilter(long, boolean) * @see FileFilterUtils#sizeRangeFileFilter(long, long) Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/SuffixFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/SuffixFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/SuffixFileFilter.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/SuffixFileFilter.java 1 Aug 2014 09:13:47 -0000 1.1.2.1 @@ -37,13 +37,8 @@ * } * * - * @since Commons IO 1.0 - * @version $Revision$ $Date$ - * - * @author Stephen Colebourne - * @author Federico Barbieri - * @author Serge Knystautas - * @author Peter Donald + * @since 1.0 + * @version $Id$ * @see FileFilterUtils#suffixFileFilter(String) * @see FileFilterUtils#suffixFileFilter(String, IOCase) */ @@ -72,14 +67,14 @@ * @param suffix the suffix to allow, must not be null * @param caseSensitivity how to handle case sensitivity, null means case-sensitive * @throws IllegalArgumentException if the suffix is null - * @since Commons IO 1.4 + * @since 1.4 */ public SuffixFileFilter(String suffix, IOCase caseSensitivity) { if (suffix == null) { throw new IllegalArgumentException("The suffix must not be null"); } this.suffixes = new String[] {suffix}; - this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; } /** @@ -105,15 +100,15 @@ * @param suffixes the suffixes to allow, must not be null * @param caseSensitivity how to handle case sensitivity, null means case-sensitive * @throws IllegalArgumentException if the suffix array is null - * @since Commons IO 1.4 + * @since 1.4 */ public SuffixFileFilter(String[] suffixes, IOCase caseSensitivity) { if (suffixes == null) { throw new IllegalArgumentException("The array of suffixes must not be null"); } this.suffixes = new String[suffixes.length]; System.arraycopy(suffixes, 0, this.suffixes, 0, suffixes.length); - this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; } /** @@ -135,14 +130,14 @@ * @param caseSensitivity how to handle case sensitivity, null means case-sensitive * @throws IllegalArgumentException if the suffix list is null * @throws ClassCastException if the list does not contain Strings - * @since Commons IO 1.4 + * @since 1.4 */ public SuffixFileFilter(List suffixes, IOCase caseSensitivity) { if (suffixes == null) { throw new IllegalArgumentException("The list of suffixes must not be null"); } this.suffixes = suffixes.toArray(new String[suffixes.size()]); - this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; } /** Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/TrueFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/TrueFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/TrueFileFilter.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/TrueFileFilter.java 1 Aug 2014 09:13:47 -0000 1.1.2.1 @@ -22,17 +22,15 @@ /** * A file filter that always returns true. * - * @since Commons IO 1.0 - * @version $Revision$ $Date$ - * - * @author Stephen Colebourne + * @since 1.0 + * @version $Id$ * @see FileFilterUtils#trueFileFilter() */ public class TrueFileFilter implements IOFileFilter, Serializable { /** * Singleton instance of true filter. - * @since Commons IO 1.3 + * @since 1.3 */ public static final IOFileFilter TRUE = new TrueFileFilter(); /** @@ -52,7 +50,7 @@ /** * Returns true. * - * @param file the file to check + * @param file the file to check (ignored) * @return true */ public boolean accept(File file) { @@ -62,8 +60,8 @@ /** * Returns true. * - * @param dir the directory to check - * @param name the filename + * @param dir the directory to check (ignored) + * @param name the filename (ignored) * @return true */ public boolean accept(File dir, String name) { Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/WildcardFileFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/WildcardFileFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/WildcardFileFilter.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/WildcardFileFilter.java 1 Aug 2014 09:13:47 -0000 1.1.2.1 @@ -45,9 +45,8 @@ * } * * - * @author Jason Anderson - * @version $Revision$ $Date$ - * @since Commons IO 1.3 + * @version $Id$ + * @since 1.3 */ public class WildcardFileFilter extends AbstractFileFilter implements Serializable { @@ -78,7 +77,7 @@ throw new IllegalArgumentException("The wildcard must not be null"); } this.wildcards = new String[] { wildcard }; - this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; } /** @@ -110,7 +109,7 @@ } this.wildcards = new String[wildcards.length]; System.arraycopy(wildcards, 0, this.wildcards, 0, wildcards.length); - this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; } /** @@ -137,14 +136,14 @@ throw new IllegalArgumentException("The wildcard list must not be null"); } this.wildcards = wildcards.toArray(new String[wildcards.size()]); - this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; } //----------------------------------------------------------------------- /** * Checks to see if the filename matches one of the wildcards. * - * @param dir the file directory + * @param dir the file directory (ignored) * @param name the filename * @return true if the filename matches one of the wildcards */ Index: 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/WildcardFilter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/filefilter/WildcardFilter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/WildcardFilter.java 1 Oct 2012 13:03:02 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/filefilter/WildcardFilter.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -44,9 +44,8 @@ * } * * - * @author Jason Anderson - * @version $Revision$ $Date$ - * @since Commons IO 1.1 + * @version $Id$ + * @since 1.1 * @deprecated Use WilcardFileFilter. Deprecated as this class performs directory * filtering which it shouldn't do, but that can't be removed due to compatability. */ Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/AutoCloseInputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/AutoCloseInputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/AutoCloseInputStream.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/AutoCloseInputStream.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -32,7 +32,7 @@ * releasing resources once the last byte has been read) do not do that. * * @version $Id$ - * @since Commons IO 1.4 + * @since 1.4 */ public class AutoCloseInputStream extends ProxyInputStream { @@ -69,7 +69,7 @@ * * @param n number of bytes read, or -1 if no more bytes are available * @throws IOException if the stream could not be closed - * @since Commons IO 2.0 + * @since 2.0 */ @Override protected void afterRead(int n) throws IOException { Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/BOMInputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/BOMInputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/BOMInputStream.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/BOMInputStream.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -19,61 +19,76 @@ import java.io.IOException; import java.io.InputStream; import java.util.Arrays; +import java.util.Comparator; import java.util.List; import org.apache.commons.io.ByteOrderMark; /** - * This class is used to wrap a stream that includes an encoded - * {@link ByteOrderMark} as its first bytes. - * - * This class detects these bytes and, if required, can automatically skip them - * and return the subsequent byte as the first byte in the stream. - * + * This class is used to wrap a stream that includes an encoded {@link ByteOrderMark} as its first bytes. + * + * This class detects these bytes and, if required, can automatically skip them and return the subsequent byte as the + * first byte in the stream. + * * The {@link ByteOrderMark} implementation has the following pre-defined BOMs: *

      - *
    • UTF-8 - {@link ByteOrderMark#UTF_8}
    • - *
    • UTF-16BE - {@link ByteOrderMark#UTF_16LE}
    • - *
    • UTF-16LE - {@link ByteOrderMark#UTF_16BE}
    • + *
    • UTF-8 - {@link ByteOrderMark#UTF_8}
    • + *
    • UTF-16BE - {@link ByteOrderMark#UTF_16LE}
    • + *
    • UTF-16LE - {@link ByteOrderMark#UTF_16BE}
    • + *
    • UTF-32BE - {@link ByteOrderMark#UTF_32LE}
    • + *
    • UTF-32LE - {@link ByteOrderMark#UTF_32BE}
    • *
    - * - * + * + * *

    Example 1 - Detect and exclude a UTF-8 BOM

    + * *
    - *      BOMInputStream bomIn = new BOMInputStream(in);
    - *      if (bomIn.hasBOM()) {
    - *          // has a UTF-8 BOM
    - *      }
    + * BOMInputStream bomIn = new BOMInputStream(in);
    + * if (bomIn.hasBOM()) {
    + *     // has a UTF-8 BOM
    + * }
      * 
    - * + * *

    Example 2 - Detect a UTF-8 BOM (but don't exclude it)

    + * *
    - *      boolean include = true;
    - *      BOMInputStream bomIn = new BOMInputStream(in, include);
    - *      if (bomIn.hasBOM()) {
    - *          // has a UTF-8 BOM
    - *      }
    + * boolean include = true;
    + * BOMInputStream bomIn = new BOMInputStream(in, include);
    + * if (bomIn.hasBOM()) {
    + *     // has a UTF-8 BOM
    + * }
      * 
    - * + * *

    Example 3 - Detect Multiple BOMs

    + * *
    - *      BOMInputStream bomIn = new BOMInputStream(in, ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_16BE);
    - *      if (bomIn.hasBOM() == false) {
    - *          // No BOM found
    - *      } else if (bomIn.hasBOM(ByteOrderMark.UTF_16LE)) {
    - *          // has a UTF-16LE BOM
    - *      } else if (bomIn.hasBOM(ByteOrderMark.UTF_16BE)) {
    - *          // has a UTF-16BE BOM
    - *      }
    + * BOMInputStream bomIn = new BOMInputStream(in, 
    + *   ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_16BE,
    + *   ByteOrderMark.UTF_32LE, ByteOrderMark.UTF_32BE
    + *   );
    + * if (bomIn.hasBOM() == false) {
    + *     // No BOM found
    + * } else if (bomIn.hasBOM(ByteOrderMark.UTF_16LE)) {
    + *     // has a UTF-16LE BOM
    + * } else if (bomIn.hasBOM(ByteOrderMark.UTF_16BE)) {
    + *     // has a UTF-16BE BOM
    + * } else if (bomIn.hasBOM(ByteOrderMark.UTF_32LE)) {
    + *     // has a UTF-32LE BOM
    + * } else if (bomIn.hasBOM(ByteOrderMark.UTF_32BE)) {
    + *     // has a UTF-32BE BOM
    + * }
      * 
    - * + * * @see org.apache.commons.io.ByteOrderMark * @see Wikipedia - Byte Order Mark - * @version $Revision$ $Date$ - * @since Commons IO 2.0 + * @version $Id$ + * @since 2.0 */ public class BOMInputStream extends ProxyInputStream { private final boolean include; + /** + * BOMs are sorted from longest to shortest. + */ private final List boms; private ByteOrderMark byteOrderMark; private int[] firstBytes; @@ -83,106 +98,138 @@ private boolean markedAtStart; /** - * Constructs a new BOM InputStream that excludes - * a {@link ByteOrderMark#UTF_8} BOM. - * @param delegate the InputStream to delegate to + * Constructs a new BOM InputStream that excludes a {@link ByteOrderMark#UTF_8} BOM. + * + * @param delegate + * the InputStream to delegate to */ public BOMInputStream(InputStream delegate) { this(delegate, false, ByteOrderMark.UTF_8); } /** - * Constructs a new BOM InputStream that detects a - * a {@link ByteOrderMark#UTF_8} and optionally includes it. - * @param delegate the InputStream to delegate to - * @param include true to include the UTF-8 BOM or - * false to exclude it + * Constructs a new BOM InputStream that detects a a {@link ByteOrderMark#UTF_8} and optionally includes it. + * + * @param delegate + * the InputStream to delegate to + * @param include + * true to include the UTF-8 BOM or false to exclude it */ public BOMInputStream(InputStream delegate, boolean include) { this(delegate, include, ByteOrderMark.UTF_8); } /** - * Constructs a new BOM InputStream that excludes - * the specified BOMs. - * @param delegate the InputStream to delegate to - * @param boms The BOMs to detect and exclude + * Constructs a new BOM InputStream that excludes the specified BOMs. + * + * @param delegate + * the InputStream to delegate to + * @param boms + * The BOMs to detect and exclude */ public BOMInputStream(InputStream delegate, ByteOrderMark... boms) { this(delegate, false, boms); } /** - * Constructs a new BOM InputStream that detects the - * specified BOMs and optionally includes them. - * @param delegate the InputStream to delegate to - * @param include true to include the specified BOMs or - * false to exclude them - * @param boms The BOMs to detect and optionally exclude + * Compares ByteOrderMark objects in descending length order. */ + private static final Comparator ByteOrderMarkLengthComparator = new Comparator() { + + public int compare(ByteOrderMark bom1, ByteOrderMark bom2) { + int len1 = bom1.length(); + int len2 = bom2.length(); + if (len1 > len2) { + return -1; + } + if (len2 > len1) { + return 1; + } + return 0; + } + }; + + /** + * Constructs a new BOM InputStream that detects the specified BOMs and optionally includes them. + * + * @param delegate + * the InputStream to delegate to + * @param include + * true to include the specified BOMs or false to exclude them + * @param boms + * The BOMs to detect and optionally exclude + */ public BOMInputStream(InputStream delegate, boolean include, ByteOrderMark... boms) { super(delegate); if (boms == null || boms.length == 0) { throw new IllegalArgumentException("No BOMs specified"); } this.include = include; + // Sort the BOMs to match the longest BOM first because some BOMs have the same starting two bytes. + Arrays.sort(boms, ByteOrderMarkLengthComparator); this.boms = Arrays.asList(boms); + } /** * Indicates whether the stream contains one of the specified BOMs. - * - * @return true if the stream has one of the specified BOMs, otherwise false - * if it does not - * @throws IOException if an error reading the first bytes of the stream occurs + * + * @return true if the stream has one of the specified BOMs, otherwise false if it does not + * @throws IOException + * if an error reading the first bytes of the stream occurs */ public boolean hasBOM() throws IOException { - return (getBOM() != null); + return getBOM() != null; } /** * Indicates whether the stream contains the specified BOM. - * - * @param bom The BOM to check for - * @return true if the stream has the specified BOM, otherwise false - * if it does not - * @throws IllegalArgumentException if the BOM is not one the stream - * is configured to detect - * @throws IOException if an error reading the first bytes of the stream occurs + * + * @param bom + * The BOM to check for + * @return true if the stream has the specified BOM, otherwise false if it does not + * @throws IllegalArgumentException + * if the BOM is not one the stream is configured to detect + * @throws IOException + * if an error reading the first bytes of the stream occurs */ public boolean hasBOM(ByteOrderMark bom) throws IOException { if (!boms.contains(bom)) { throw new IllegalArgumentException("Stream not configure to detect " + bom); } - return (byteOrderMark != null && getBOM().equals(bom)); + return byteOrderMark != null && getBOM().equals(bom); } /** * Return the BOM (Byte Order Mark). - * + * * @return The BOM or null if none - * @throws IOException if an error reading the first bytes of the stream occurs + * @throws IOException + * if an error reading the first bytes of the stream occurs */ public ByteOrderMark getBOM() throws IOException { if (firstBytes == null) { - int max = 0; - for (ByteOrderMark bom : boms) { - max = Math.max(max, bom.length()); - } - firstBytes = new int[max]; + fbLength = 0; + // BOMs are sorted from longest to shortest + final int maxBomSize = boms.get(0).length(); + firstBytes = new int[maxBomSize]; + // Read first maxBomSize bytes for (int i = 0; i < firstBytes.length; i++) { firstBytes[i] = in.read(); fbLength++; if (firstBytes[i] < 0) { break; } - - byteOrderMark = find(); - if (byteOrderMark != null) { - if (!include) { + } + // match BOM in firstBytes + byteOrderMark = find(); + if (byteOrderMark != null) { + if (!include) { + if (byteOrderMark.length() < firstBytes.length) { + fbIndex = byteOrderMark.length(); + } else { fbLength = 0; } - break; } } } @@ -191,32 +238,34 @@ /** * Return the BOM charset Name - {@link ByteOrderMark#getCharsetName()}. - * + * * @return The BOM charset Name or null if no BOM found - * @throws IOException if an error reading the first bytes of the stream occurs + * @throws IOException + * if an error reading the first bytes of the stream occurs * */ public String getBOMCharsetName() throws IOException { getBOM(); - return (byteOrderMark == null ? null : byteOrderMark.getCharsetName()); + return byteOrderMark == null ? null : byteOrderMark.getCharsetName(); } /** - * This method reads and either preserves or skips the first bytes in the - * stream. It behaves like the single-byte read() method, - * either returning a valid byte or -1 to indicate that the initial bytes - * have been processed already. + * This method reads and either preserves or skips the first bytes in the stream. It behaves like the single-byte + * read() method, either returning a valid byte or -1 to indicate that the initial bytes have been + * processed already. + * * @return the byte read (excluding BOM) or -1 if the end of stream - * @throws IOException if an I/O error occurs + * @throws IOException + * if an I/O error occurs */ private int readFirstBytes() throws IOException { getBOM(); - return (fbIndex < fbLength) ? firstBytes[fbIndex++] : -1; + return fbIndex < fbLength ? firstBytes[fbIndex++] : -1; } /** * Find a BOM with the specified bytes. - * + * * @return The matched BOM or null if none matched */ private ByteOrderMark find() { @@ -230,14 +279,16 @@ /** * Check if the bytes match a BOM. - * - * @param bom The BOM + * + * @param bom + * The BOM * @return true if the bytes match the bom, otherwise false */ private boolean matches(ByteOrderMark bom) { - if (bom.length() != fbLength) { - return false; - } + // if (bom.length() != fbLength) { + // return false; + // } + // firstBytes may be bigger than the BOM bytes for (int i = 0; i < bom.length(); i++) { if (bom.get(i) != firstBytes[i]) { return false; @@ -246,36 +297,41 @@ return true; } - //---------------------------------------------------------------------------- - // Implementation of InputStream - //---------------------------------------------------------------------------- + // ---------------------------------------------------------------------------- + // Implementation of InputStream + // ---------------------------------------------------------------------------- /** - * Invokes the delegate's read() method, detecting and - * optionally skipping BOM. + * Invokes the delegate's read() method, detecting and optionally skipping BOM. + * * @return the byte read (excluding BOM) or -1 if the end of stream - * @throws IOException if an I/O error occurs + * @throws IOException + * if an I/O error occurs */ @Override public int read() throws IOException { int b = readFirstBytes(); - return (b >= 0) ? b : in.read(); + return b >= 0 ? b : in.read(); } /** - * Invokes the delegate's read(byte[], int, int) method, detecting - * and optionally skipping BOM. - * @param buf the buffer to read the bytes into - * @param off The start offset - * @param len The number of bytes to read (excluding BOM) + * Invokes the delegate's read(byte[], int, int) method, detecting and optionally skipping BOM. + * + * @param buf + * the buffer to read the bytes into + * @param off + * The start offset + * @param len + * The number of bytes to read (excluding BOM) * @return the number of bytes read or -1 if the end of stream - * @throws IOException if an I/O error occurs + * @throws IOException + * if an I/O error occurs */ @Override public int read(byte[] buf, int off, int len) throws IOException { int firstCount = 0; int b = 0; - while ((len > 0) && (b >= 0)) { + while (len > 0 && b >= 0) { b = readFirstBytes(); if (b >= 0) { buf[off++] = (byte) (b & 0xFF); @@ -284,16 +340,17 @@ } } int secondCount = in.read(buf, off, len); - return (secondCount < 0) ? (firstCount > 0 ? firstCount : -1) : firstCount + secondCount; + return secondCount < 0 ? firstCount > 0 ? firstCount : -1 : firstCount + secondCount; } /** - * Invokes the delegate's read(byte[]) method, detecting and - * optionally skipping BOM. - * @param buf the buffer to read the bytes into - * @return the number of bytes read (excluding BOM) - * or -1 if the end of stream - * @throws IOException if an I/O error occurs + * Invokes the delegate's read(byte[]) method, detecting and optionally skipping BOM. + * + * @param buf + * the buffer to read the bytes into + * @return the number of bytes read (excluding BOM) or -1 if the end of stream + * @throws IOException + * if an I/O error occurs */ @Override public int read(byte[] buf) throws IOException { @@ -302,18 +359,22 @@ /** * Invokes the delegate's mark(int) method. - * @param readlimit read ahead limit + * + * @param readlimit + * read ahead limit */ @Override public synchronized void mark(int readlimit) { markFbIndex = fbIndex; - markedAtStart = (firstBytes == null); + markedAtStart = firstBytes == null; in.mark(readlimit); } /** * Invokes the delegate's reset() method. - * @throws IOException if an I/O error occurs + * + * @throws IOException + * if an I/O error occurs */ @Override public synchronized void reset() throws IOException { @@ -326,15 +387,17 @@ } /** - * Invokes the delegate's skip(long) method, detecting - * and optionallyskipping BOM. - * @param n the number of bytes to skip + * Invokes the delegate's skip(long) method, detecting and optionallyskipping BOM. + * + * @param n + * the number of bytes to skip * @return the number of bytes to skipped or -1 if the end of stream - * @throws IOException if an I/O error occurs + * @throws IOException + * if an I/O error occurs */ @Override public long skip(long n) throws IOException { - while ((n > 0) && (readFirstBytes() >= 0)) { + while (n > 0 && readFirstBytes() >= 0) { n--; } return in.skip(n); Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/BoundedInputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/BoundedInputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/BoundedInputStream.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/BoundedInputStream.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -31,7 +31,7 @@ * with a correct content length. * * @version $Id$ - * @since Commons IO 2.0 + * @since 2.0 */ public class BoundedInputStream extends InputStream { @@ -83,7 +83,7 @@ */ @Override public int read() throws IOException { - if (max>=0 && pos==max) { + if (max >= 0 && pos >= max) { return -1; } int result = in.read(); @@ -164,7 +164,7 @@ /** * Invokes the delegate's close() method - * if {@link #isPropagateClose()} is true. + * if {@link #isPropagateClose()} is {@code true}. * @throws IOException if an I/O error occurs */ @Override @@ -207,9 +207,9 @@ * Indicates whether the {@link #close()} method * should propagate to the underling {@link InputStream}. * - * @return true if calling {@link #close()} + * @return {@code true} if calling {@link #close()} * propagates to the close() method of the - * underlying stream or false if it does not. + * underlying stream or {@code false} if it does not. */ public boolean isPropagateClose() { return propagateClose; @@ -219,10 +219,10 @@ * Set whether the {@link #close()} method * should propagate to the underling {@link InputStream}. * - * @param propagateClose true if calling + * @param propagateClose {@code true} if calling * {@link #close()} propagates to the close() * method of the underlying stream or - * false if it does not. + * {@code false} if it does not. */ public void setPropagateClose(boolean propagateClose) { this.propagateClose = propagateClose; Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/BrokenInputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/BrokenInputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/BrokenInputStream.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/BrokenInputStream.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -26,7 +26,7 @@ * This class is mostly useful for testing error handling in code that uses an * input stream. * - * @since Commons IO 2.0 + * @since 2.0 */ public class BrokenInputStream extends InputStream { Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/commons-io/org/apache/commons/io/input/CharSequenceInputStream.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/CharSequenceReader.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/CharSequenceReader.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/CharSequenceReader.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/CharSequenceReader.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -25,8 +25,8 @@ *

    * Note: Supports {@link #mark(int)} and {@link #reset()}. * - * @version $Revision$ $Date$ - * @since Commons IO 1.4 + * @version $Id$ + * @since 1.4 */ public class CharSequenceReader extends Reader implements Serializable { @@ -37,10 +37,10 @@ /** * Construct a new instance with the specified character sequence. * - * @param charSequence The character sequence, may be null + * @param charSequence The character sequence, may be {@code null} */ public CharSequenceReader(CharSequence charSequence) { - this.charSequence = (charSequence != null ? charSequence : ""); + this.charSequence = charSequence != null ? charSequence : ""; } /** @@ -65,7 +65,7 @@ /** * Mark is supported (returns true). * - * @return true + * @return {@code true} */ @Override public boolean markSupported() { @@ -104,7 +104,7 @@ if (array == null) { throw new NullPointerException("Character array is missing"); } - if (length < 0 || (offset + length) > array.length) { + if (length < 0 || offset < 0 || offset + length > array.length) { throw new IndexOutOfBoundsException("Array Size=" + array.length + ", offset=" + offset + ", length=" + length); } @@ -144,7 +144,7 @@ if (idx >= charSequence.length()) { return -1; } - int dest = (int)Math.min(charSequence.length(), (idx + n)); + int dest = (int)Math.min(charSequence.length(), idx + n); int count = dest - idx; idx = dest; return count; Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/ClassLoaderObjectInputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/ClassLoaderObjectInputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/ClassLoaderObjectInputStream.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/ClassLoaderObjectInputStream.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -29,9 +29,8 @@ *

    * This is useful in dynamic container environments. * - * @author Paul Hammant * @version $Id$ - * @since Commons IO 1.1 + * @since 1.1 */ public class ClassLoaderObjectInputStream extends ObjectInputStream { @@ -86,7 +85,7 @@ * @throws IOException in case of an I/O error * @throws ClassNotFoundException if the Class cannot be found * @see java.io.ObjectInputStream#resolveProxyClass(java.lang.String[]) - * @since Commons IO 2.1 + * @since 2.1 */ @Override protected Class resolveProxyClass(String[] interfaces) throws IOException, Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/CloseShieldInputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/CloseShieldInputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/CloseShieldInputStream.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/CloseShieldInputStream.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -26,7 +26,7 @@ * more input would still be available to other components. * * @version $Id$ - * @since Commons IO 1.4 + * @since 1.4 */ public class CloseShieldInputStream extends ProxyInputStream { Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/ClosedInputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/ClosedInputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/ClosedInputStream.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/ClosedInputStream.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -24,10 +24,10 @@ *

    * Typically uses of this class include testing for corner cases in methods * that accept input streams and acting as a sentinel value instead of a - * null input stream. + * {@code null} input stream. * * @version $Id$ - * @since Commons IO 1.4 + * @since 1.4 */ public class ClosedInputStream extends InputStream { Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/CountingInputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/CountingInputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/CountingInputStream.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/CountingInputStream.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -26,7 +26,6 @@ * A typical use case would be during debugging, to ensure that data is being * read as expected. * - * @author Marcelo Liberato * @version $Id$ */ public class CountingInputStream extends ProxyInputStream { @@ -65,7 +64,7 @@ * Adds the number of read bytes to the count. * * @param n number of bytes read, or -1 if no more bytes are available - * @since Commons IO 2.0 + * @since 2.0 */ @Override protected synchronized void afterRead(int n) { @@ -119,7 +118,7 @@ * result in incorrect count for files over 2GB. * * @return the number of bytes accumulated - * @since Commons IO 1.3 + * @since 1.3 */ public synchronized long getByteCount() { return this.count; @@ -133,7 +132,7 @@ * result in incorrect count for files over 2GB. * * @return the count previous to resetting - * @since Commons IO 1.3 + * @since 1.3 */ public synchronized long resetByteCount() { long tmp = this.count; Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/DemuxInputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/DemuxInputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/DemuxInputStream.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/DemuxInputStream.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -23,8 +23,7 @@ * Data written to this stream is forwarded to a stream that has been associated * with this thread. * - * @author Peter Donald - * @version $Revision$ $Date$ + * @version $Id$ */ public class DemuxInputStream extends InputStream Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/NullInputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/NullInputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/NullInputStream.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/NullInputStream.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -57,8 +57,8 @@ * } * * - * @since Commons IO 1.3 - * @version $Revision$ + * @since 1.3 + * @version $Id$ */ public class NullInputStream extends InputStream { @@ -176,9 +176,9 @@ * * @return Either The byte value returned by processByte() * or -1 if the end of file has been reached and - * throwEofException is set to false. + * throwEofException is set to {@code false}. * @throws EOFException if the end of file is reached and - * throwEofException is set to true. + * throwEofException is set to {@code true}. * @throws IOException if trying to read past the end of file. */ @Override @@ -199,9 +199,9 @@ * @param bytes The byte array to read into * @return The number of bytes read or -1 * if the end of file has been reached and - * throwEofException is set to false. + * throwEofException is set to {@code false}. * @throws EOFException if the end of file is reached and - * throwEofException is set to true. + * throwEofException is set to {@code true}. * @throws IOException if trying to read past the end of file. */ @Override @@ -217,9 +217,9 @@ * @param length The number of bytes to read. * @return The number of bytes read or -1 * if the end of file has been reached and - * throwEofException is set to false. + * throwEofException is set to {@code false}. * @throws EOFException if the end of file is reached and - * throwEofException is set to true. + * throwEofException is set to {@code true}. * @throws IOException if trying to read past the end of file. */ @Override @@ -256,7 +256,7 @@ if (mark < 0) { throw new IOException("No position has been marked"); } - if (position > (mark + readlimit)) { + if (position > mark + readlimit) { throw new IOException("Marked position [" + mark + "] is no longer valid - passed the read limit [" + readlimit + "]"); @@ -271,9 +271,9 @@ * @param numberOfBytes The number of bytes to skip. * @return The number of bytes skipped or -1 * if the end of file has been reached and - * throwEofException is set to false. + * throwEofException is set to {@code false}. * @throws EOFException if the end of file is reached and - * throwEofException is set to true. + * throwEofException is set to {@code true}. * @throws IOException if trying to read past the end of file. */ @Override @@ -323,9 +323,9 @@ * Handle End of File. * * @return -1 if throwEofException is - * set to false + * set to {@code false} * @throws EOFException if throwEofException is set - * to true. + * to {@code true}. */ private int doEndOfFile() throws EOFException { eof = true; Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/NullReader.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/NullReader.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/NullReader.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/NullReader.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -57,8 +57,8 @@ * } * * - * @since Commons IO 1.3 - * @version $Revision$ + * @since 1.3 + * @version $Id$ */ public class NullReader extends Reader { @@ -159,9 +159,9 @@ * * @return Either The character value returned by processChar() * or -1 if the end of file has been reached and - * throwEofException is set to false. + * throwEofException is set to {@code false}. * @throws EOFException if the end of file is reached and - * throwEofException is set to true. + * throwEofException is set to {@code true}. * @throws IOException if trying to read past the end of file. */ @Override @@ -182,9 +182,9 @@ * @param chars The character array to read into * @return The number of characters read or -1 * if the end of file has been reached and - * throwEofException is set to false. + * throwEofException is set to {@code false}. * @throws EOFException if the end of file is reached and - * throwEofException is set to true. + * throwEofException is set to {@code true}. * @throws IOException if trying to read past the end of file. */ @Override @@ -200,9 +200,9 @@ * @param length The number of characters to read. * @return The number of characters read or -1 * if the end of file has been reached and - * throwEofException is set to false. + * throwEofException is set to {@code false}. * @throws EOFException if the end of file is reached and - * throwEofException is set to true. + * throwEofException is set to {@code true}. * @throws IOException if trying to read past the end of file. */ @Override @@ -239,7 +239,7 @@ if (mark < 0) { throw new IOException("No position has been marked"); } - if (position > (mark + readlimit)) { + if (position > mark + readlimit) { throw new IOException("Marked position [" + mark + "] is no longer valid - passed the read limit [" + readlimit + "]"); @@ -254,9 +254,9 @@ * @param numberOfChars The number of characters to skip. * @return The number of characters skipped or -1 * if the end of file has been reached and - * throwEofException is set to false. + * throwEofException is set to {@code false}. * @throws EOFException if the end of file is reached and - * throwEofException is set to true. + * throwEofException is set to {@code true}. * @throws IOException if trying to read past the end of file. */ @Override @@ -306,9 +306,9 @@ * Handle End of File. * * @return -1 if throwEofException is - * set to false + * set to {@code false} * @throws EOFException if throwEofException is set - * to true. + * to {@code true}. */ private int doEndOfFile() throws EOFException { eof = true; Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/ProxyInputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/ProxyInputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/ProxyInputStream.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/ProxyInputStream.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -32,7 +32,6 @@ * See the protected methods for ways in which a subclass can easily decorate * a stream with custom pre-, post- or error processing functionality. * - * @author Stephen Colebourne * @version $Id$ */ public abstract class ProxyInputStream extends FilterInputStream { @@ -194,7 +193,7 @@ * {@link #reset()}. You need to explicitly override those methods if * you want to add pre-processing steps also to them. * - * @since Commons IO 2.0 + * @since 2.0 * @param n number of bytes that the caller asked to be read * @throws IOException if the pre-processing fails */ @@ -214,7 +213,7 @@ * {@link #reset()}. You need to explicitly override those methods if * you want to add post-processing steps also to them. * - * @since Commons IO 2.0 + * @since 2.0 * @param n number of bytes read, or -1 if the end of stream was reached * @throws IOException if the post-processing fails */ @@ -228,7 +227,7 @@ * handling. The default behaviour is to re-throw the exception. * @param e The IOException thrown * @throws IOException if an I/O error occurs - * @since Commons IO 2.0 + * @since 2.0 */ protected void handleIOException(IOException e) throws IOException { throw e; Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/ProxyReader.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/ProxyReader.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/ProxyReader.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/ProxyReader.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -30,7 +30,6 @@ * to increase reusability, because FilterReader changes the * methods being called, such as read(char[]) to read(char[], int, int). * - * @author Stephen Colebourne * @version $Id$ */ public abstract class ProxyReader extends FilterReader { @@ -108,7 +107,7 @@ * @param target the char buffer to read the characters into * @return the number of characters read or -1 if the end of stream * @throws IOException if an I/O error occurs - * @since Commons IO 2.0 + * @since 2.0 */ @Override public int read(CharBuffer target) throws IOException { @@ -217,7 +216,7 @@ * {@link #reset()}. You need to explicitly override those methods if * you want to add pre-processing steps also to them. * - * @since Commons IO 2.0 + * @since 2.0 * @param n number of chars that the caller asked to be read * @throws IOException if the pre-processing fails */ @@ -237,7 +236,7 @@ * {@link #reset()}. You need to explicitly override those methods if * you want to add post-processing steps also to them. * - * @since Commons IO 2.0 + * @since 2.0 * @param n number of chars read, or -1 if the end of stream was reached * @throws IOException if the post-processing fails */ @@ -251,7 +250,7 @@ * handling. The default behaviour is to re-throw the exception. * @param e The IOException thrown * @throws IOException if an I/O error occurs - * @since Commons IO 2.0 + * @since 2.0 */ protected void handleIOException(IOException e) throws IOException { throw e; Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/ReaderInputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/ReaderInputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/ReaderInputStream.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/ReaderInputStream.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -72,8 +72,7 @@ * * @see org.apache.commons.io.output.WriterOutputStream * - * @author Andreas Veithen - * @since Commons IO 2.0 + * @since 2.0 */ public class ReaderInputStream extends InputStream { private static final int DEFAULT_BUFFER_SIZE = 1024; @@ -92,7 +91,7 @@ * as it is only used to transfer data from the decoder to the * buffer provided by the caller. */ - private final ByteBuffer encoderOut = ByteBuffer.allocate(128); + private final ByteBuffer encoderOut; private CoderResult lastCoderResult; private boolean endOfInput; @@ -102,7 +101,7 @@ * * @param reader the target {@link Reader} * @param encoder the charset encoder - * @since Commons IO 2.1 + * @since 2.1 */ public ReaderInputStream(Reader reader, CharsetEncoder encoder) { this(reader, encoder, DEFAULT_BUFFER_SIZE); @@ -114,13 +113,15 @@ * @param reader the target {@link Reader} * @param encoder the charset encoder * @param bufferSize the size of the input buffer in number of characters - * @since Commons IO 2.1 + * @since 2.1 */ public ReaderInputStream(Reader reader, CharsetEncoder encoder, int bufferSize) { this.reader = reader; this.encoder = encoder; - encoderIn = CharBuffer.allocate(bufferSize); - encoderIn.flip(); + this.encoderIn = CharBuffer.allocate(bufferSize); + this.encoderIn.flip(); + this.encoderOut = ByteBuffer.allocate(128); + this.encoderOut.flip(); } /** @@ -182,6 +183,32 @@ } /** + * Fills the internal char buffer from the reader. + * + * @throws IOException + * If an I/O error occurs + */ + private void fillBuffer() throws IOException { + if (!endOfInput && (lastCoderResult == null || lastCoderResult.isUnderflow())) { + encoderIn.compact(); + int position = encoderIn.position(); + // We don't use Reader#read(CharBuffer) here because it is more efficient + // to write directly to the underlying char array (the default implementation + // copies data to a temporary char array). + int c = reader.read(encoderIn.array(), position, encoderIn.remaining()); + if (c == -1) { + endOfInput = true; + } else { + encoderIn.position(position+c); + } + encoderIn.flip(); + } + encoderOut.compact(); + lastCoderResult = encoder.encode(encoderIn, encoderOut, endOfInput); + encoderOut.flip(); + } + + /** * Read the specified number of bytes into an array. * * @param b the byte array to read into @@ -193,33 +220,27 @@ */ @Override public int read(byte[] b, int off, int len) throws IOException { + if (b == null) { + throw new NullPointerException("Byte array must not be null"); + } + if (len < 0 || off < 0 || (off + len) > b.length) { + throw new IndexOutOfBoundsException("Array Size=" + b.length + + ", offset=" + off + ", length=" + len); + } int read = 0; + if (len == 0) { + return 0; // Always return 0 if len == 0 + } while (len > 0) { - if (encoderOut.position() > 0) { - encoderOut.flip(); + if (encoderOut.hasRemaining()) { int c = Math.min(encoderOut.remaining(), len); encoderOut.get(b, off, c); off += c; len -= c; read += c; - encoderOut.compact(); } else { - if (!endOfInput && (lastCoderResult == null || lastCoderResult.isUnderflow())) { - encoderIn.compact(); - int position = encoderIn.position(); - // We don't use Reader#read(CharBuffer) here because it is more efficient - // to write directly to the underlying char array (the default implementation - // copies data to a temporary char array). - int c = reader.read(encoderIn.array(), position, encoderIn.remaining()); - if (c == -1) { - endOfInput = true; - } else { - encoderIn.position(position+c); - } - encoderIn.flip(); - } - lastCoderResult = encoder.encode(encoderIn, encoderOut, endOfInput); - if (endOfInput && encoderOut.position() == 0) { + fillBuffer(); + if (endOfInput && !encoderOut.hasRemaining()) { break; } } @@ -249,8 +270,16 @@ */ @Override public int read() throws IOException { - byte[] b = new byte[1]; - return read(b) == -1 ? -1 : b[0] & 0xFF; + for (;;) { + if (encoderOut.hasRemaining()) { + return encoderOut.get() & 0xFF; + } else { + fillBuffer(); + if (endOfInput && !encoderOut.hasRemaining()) { + return -1; + } + } + } } /** Fisheye: Tag 1.1 refers to a dead (removed) revision in file `3rdParty_sources/commons-io/org/apache/commons/io/input/ReversedLinesFileReader.java'. Fisheye: No comparison available. Pass `N' to diff? Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/SwappedDataInputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/SwappedDataInputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/SwappedDataInputStream.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/SwappedDataInputStream.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -30,8 +30,7 @@ *

    * Origin of code: Avalon Excalibur (IO) * - * @author Peter Donald - * @version CVS $Revision$ $Date$ + * @version CVS $Revision$ */ public class SwappedDataInputStream extends ProxyInputStream implements DataInput @@ -56,7 +55,7 @@ public boolean readBoolean() throws IOException, EOFException { - return ( 0 != readByte() ); + return 0 != readByte(); } /** @@ -137,7 +136,7 @@ while( remaining > 0 ) { - int location = offset + ( length - remaining ); + int location = offset + length - remaining; int count = read( data, location, remaining ); if( -1 == count ) Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/TaggedInputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/TaggedInputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/TaggedInputStream.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/TaggedInputStream.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -59,7 +59,7 @@ * * * @see TaggedIOException - * @since Commons IO 2.0 + * @since 2.0 */ public class TaggedInputStream extends ProxyInputStream { @@ -81,8 +81,8 @@ * Tests if the given exception was caused by this stream. * * @param exception an exception - * @return true if the exception was thrown by this stream, - * false otherwise + * @return {@code true} if the exception was thrown by this stream, + * {@code false} otherwise */ public boolean isCauseOf(Throwable exception) { return TaggedIOException.isTaggedWith(exception, tag); Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/Tailer.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/Tailer.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/Tailer.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/Tailer.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -102,19 +102,30 @@ * @see TailerListener * @see TailerListenerAdapter * @version $Id$ - * @since Commons IO 2.0 + * @since 2.0 */ public class Tailer implements Runnable { + private static final int DEFAULT_DELAY_MILLIS = 1000; + + private static final String RAF_MODE = "r"; + + private static final int DEFAULT_BUFSIZE = 4096; + /** + * Buffer on top of RandomAccessFile. + */ + private final byte inbuf[]; + + /** * The file which will be tailed. */ private final File file; /** * The amount of time to wait for the file to be updated. */ - private final long delay; + private final long delayMillis; /** * Whether to tail from the end or start of file @@ -127,6 +138,11 @@ private final TailerListener listener; /** + * Whether to close and reopen the file whilst waiting for more input. + */ + private final boolean reOpen; + + /** * The tailer will run as long as this value is true. */ private volatile boolean run = true; @@ -137,64 +153,151 @@ * @param listener the TailerListener to use. */ public Tailer(File file, TailerListener listener) { - this(file, listener, 1000); + this(file, listener, DEFAULT_DELAY_MILLIS); } /** * Creates a Tailer for the given file, starting from the beginning. * @param file the file to follow. * @param listener the TailerListener to use. - * @param delay the delay between checks of the file for new content in milliseconds. + * @param delayMillis the delay between checks of the file for new content in milliseconds. */ - public Tailer(File file, TailerListener listener, long delay) { - this(file, listener, 1000, false); + public Tailer(File file, TailerListener listener, long delayMillis) { + this(file, listener, delayMillis, false); } /** * Creates a Tailer for the given file, with a delay other than the default 1.0s. * @param file the file to follow. * @param listener the TailerListener to use. - * @param delay the delay between checks of the file for new content in milliseconds. + * @param delayMillis the delay between checks of the file for new content in milliseconds. * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. */ - public Tailer(File file, TailerListener listener, long delay, boolean end) { - + public Tailer(File file, TailerListener listener, long delayMillis, boolean end) { + this(file, listener, delayMillis, end, DEFAULT_BUFSIZE); + } + + /** + * Creates a Tailer for the given file, with a delay other than the default 1.0s. + * @param file the file to follow. + * @param listener the TailerListener to use. + * @param delayMillis the delay between checks of the file for new content in milliseconds. + * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. + * @param reOpen if true, close and reopen the file between reading chunks + */ + public Tailer(File file, TailerListener listener, long delayMillis, boolean end, boolean reOpen) { + this(file, listener, delayMillis, end, reOpen, DEFAULT_BUFSIZE); + } + + /** + * Creates a Tailer for the given file, with a specified buffer size. + * @param file the file to follow. + * @param listener the TailerListener to use. + * @param delayMillis the delay between checks of the file for new content in milliseconds. + * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. + * @param bufSize Buffer size + */ + public Tailer(File file, TailerListener listener, long delayMillis, boolean end, int bufSize) { + this(file, listener, delayMillis, end, false, bufSize); + } + + /** + * Creates a Tailer for the given file, with a specified buffer size. + * @param file the file to follow. + * @param listener the TailerListener to use. + * @param delayMillis the delay between checks of the file for new content in milliseconds. + * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. + * @param reOpen if true, close and reopen the file between reading chunks + * @param bufSize Buffer size + */ + public Tailer(File file, TailerListener listener, long delayMillis, boolean end, boolean reOpen, int bufSize) { this.file = file; - this.delay = delay; + this.delayMillis = delayMillis; this.end = end; + + this.inbuf = new byte[bufSize]; // Save and prepare the listener this.listener = listener; listener.init(this); + this.reOpen = reOpen; } + + /** + * Creates and starts a Tailer for the given file. + * + * @param file the file to follow. + * @param listener the TailerListener to use. + * @param delayMillis the delay between checks of the file for new content in milliseconds. + * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. + * @param bufSize buffer size. + * @return The new tailer + */ + public static Tailer create(File file, TailerListener listener, long delayMillis, boolean end, int bufSize) { + Tailer tailer = new Tailer(file, listener, delayMillis, end, bufSize); + Thread thread = new Thread(tailer); + thread.setDaemon(true); + thread.start(); + return tailer; + } /** * Creates and starts a Tailer for the given file. * * @param file the file to follow. * @param listener the TailerListener to use. - * @param delay the delay between checks of the file for new content in milliseconds. + * @param delayMillis the delay between checks of the file for new content in milliseconds. * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. + * @param reOpen whether to close/reopen the file between chunks + * @param bufSize buffer size. * @return The new tailer */ - public static Tailer create(File file, TailerListener listener, long delay, boolean end) { - Tailer tailer = new Tailer(file, listener, delay, end); + public static Tailer create(File file, TailerListener listener, long delayMillis, boolean end, boolean reOpen, + int bufSize) { + Tailer tailer = new Tailer(file, listener, delayMillis, end, reOpen, bufSize); Thread thread = new Thread(tailer); thread.setDaemon(true); thread.start(); return tailer; } /** + * Creates and starts a Tailer for the given file with default buffer size. + * + * @param file the file to follow. + * @param listener the TailerListener to use. + * @param delayMillis the delay between checks of the file for new content in milliseconds. + * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. + * @return The new tailer + */ + public static Tailer create(File file, TailerListener listener, long delayMillis, boolean end) { + return create(file, listener, delayMillis, end, DEFAULT_BUFSIZE); + } + + /** + * Creates and starts a Tailer for the given file with default buffer size. + * + * @param file the file to follow. + * @param listener the TailerListener to use. + * @param delayMillis the delay between checks of the file for new content in milliseconds. + * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. + * @param reOpen whether to close/reopen the file between chunks + * @return The new tailer + */ + public static Tailer create(File file, TailerListener listener, long delayMillis, boolean end, boolean reOpen) { + return create(file, listener, delayMillis, end, reOpen, DEFAULT_BUFSIZE); + } + + /** * Creates and starts a Tailer for the given file, starting at the beginning of the file * * @param file the file to follow. * @param listener the TailerListener to use. - * @param delay the delay between checks of the file for new content in milliseconds. + * @param delayMillis the delay between checks of the file for new content in milliseconds. * @return The new tailer */ - public static Tailer create(File file, TailerListener listener, long delay) { - return create(file, listener, delay, false); + public static Tailer create(File file, TailerListener listener, long delayMillis) { + return create(file, listener, delayMillis, false); } /** @@ -206,7 +309,7 @@ * @return The new tailer */ public static Tailer create(File file, TailerListener listener) { - return create(file, listener, 1000, false); + return create(file, listener, DEFAULT_DELAY_MILLIS, false); } /** @@ -219,12 +322,12 @@ } /** - * Return the delay. + * Return the delay in milliseconds. * - * @return the delay + * @return the delay in milliseconds. */ public long getDelay() { - return delay; + return delayMillis; } /** @@ -238,27 +341,28 @@ // Open the file while (run && reader == null) { try { - reader = new RandomAccessFile(file, "r"); + reader = new RandomAccessFile(file, RAF_MODE); } catch (FileNotFoundException e) { listener.fileNotFound(); } if (reader == null) { try { - Thread.sleep(delay); + Thread.sleep(delayMillis); } catch (InterruptedException e) { } } else { // The current position in the file position = end ? file.length() : 0; last = System.currentTimeMillis(); - reader.seek(position); + reader.seek(position); } } - while (run) { + boolean newer = FileUtils.isFileNewer(file, last); // IO-279, must be done first + // Check the file length to see if it was rotated long length = file.length(); @@ -271,7 +375,7 @@ try { // Ensure that the old file is closed iff we re-open it successfully RandomAccessFile save = reader; - reader = new RandomAccessFile(file, "r"); + reader = new RandomAccessFile(file, RAF_MODE); position = 0; // close old file explicitly rather than relying on GC picking up previous RAF IOUtils.closeQuietly(save); @@ -288,27 +392,34 @@ if (length > position) { // The file has more content than it did last time - last = System.currentTimeMillis(); position = readLines(reader); + last = System.currentTimeMillis(); - } else if (FileUtils.isFileNewer(file, last)) { + } else if (newer) { - /* This can happen if the file is truncated or overwritten - * with the exact same length of information. In cases like - * this, the file position needs to be reset + /* + * This can happen if the file is truncated or overwritten with the exact same length of + * information. In cases like this, the file position needs to be reset */ position = 0; reader.seek(position); // cannot be null here // Now we can read new lines - last = System.currentTimeMillis(); position = readLines(reader); + last = System.currentTimeMillis(); } } + if (reOpen) { + IOUtils.closeQuietly(reader); + } try { - Thread.sleep(delay); + Thread.sleep(delayMillis); } catch (InterruptedException e) { } + if (run && reOpen) { + reader = new RandomAccessFile(file, RAF_MODE); + reader.seek(position); + } } } catch (Exception e) { @@ -335,42 +446,45 @@ * @throws java.io.IOException if an I/O error occurs. */ private long readLines(RandomAccessFile reader) throws IOException { + StringBuilder sb = new StringBuilder(); + long pos = reader.getFilePointer(); - String line = readLine(reader); - while (line != null) { - pos = reader.getFilePointer(); - listener.handle(line); - line = readLine(reader); - } - reader.seek(pos); // Ensure we can re-read if necessary - return pos; - } + long rePos = pos; // position to re-read - /** - * Version of readline() that returns null on EOF rather than a partial line. - * @param reader the input file - * @return the line, or null if EOF reached before '\n' is seen. - * @throws IOException if an error occurs. - */ - private String readLine(RandomAccessFile reader) throws IOException { - StringBuffer sb = new StringBuffer(); - int ch; + int num; boolean seenCR = false; - while((ch=reader.read()) != -1) { - switch(ch) { + while (run && ((num = reader.read(inbuf)) != -1)) { + for (int i = 0; i < num; i++) { + byte ch = inbuf[i]; + switch (ch) { case '\n': - return sb.toString(); + seenCR = false; // swallow CR before LF + listener.handle(sb.toString()); + sb.setLength(0); + rePos = pos + i + 1; + break; case '\r': + if (seenCR) { + sb.append('\r'); + } seenCR = true; break; default: if (seenCR) { - sb.append('\r'); - seenCR = false; + seenCR = false; // swallow final CR + listener.handle(sb.toString()); + sb.setLength(0); + rePos = pos + i + 1; } - sb.append((char)ch); // add character, not its ascii value + sb.append((char) ch); // add character, not its ascii value + } } + + pos = reader.getFilePointer(); } - return null; + + reader.seek(rePos); // Ensure we can re-read if necessary + return rePos; } + } Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/TailerListener.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/TailerListener.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/TailerListener.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/TailerListener.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -20,7 +20,7 @@ * Listener for events from a {@link Tailer}. * * @version $Id$ - * @since Commons IO 2.0 + * @since 2.0 */ public interface TailerListener { Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/TailerListenerAdapter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/TailerListenerAdapter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/TailerListenerAdapter.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/TailerListenerAdapter.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -20,7 +20,7 @@ * {@link TailerListener} Adapter. * * @version $Id$ - * @since Commons IO 2.0 + * @since 2.0 */ public class TailerListenerAdapter implements TailerListener { Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/TeeInputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/TeeInputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/TeeInputStream.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/TeeInputStream.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -32,7 +32,7 @@ * stream will also closed. * * @version $Id$ - * @since Commons IO 1.4 + * @since 1.4 */ public class TeeInputStream extends ProxyInputStream { @@ -64,7 +64,7 @@ * Creates a TeeInputStream that proxies the given {@link InputStream} * and copies all read bytes to the given {@link OutputStream}. The given * output stream will be closed when this stream gets closed if the - * closeBranch parameter is true. + * closeBranch parameter is {@code true}. * * @param input input stream to be proxied * @param branch output stream that will receive a copy of all bytes read Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/XmlStreamReader.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/XmlStreamReader.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/XmlStreamReader.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/XmlStreamReader.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -29,6 +29,7 @@ import java.net.URL; import java.net.URLConnection; import java.text.MessageFormat; +import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -58,10 +59,9 @@ * Originally developed for ROME under * Apache License 2.0. * - * @author Alejandro Abdelnur * @version $Id$ * @see org.apache.commons.io.output.XmlStreamWriter - * @since Commons IO 2.0 + * @since 2.0 */ public class XmlStreamReader extends Reader { private static final int BUFFER_SIZE = 4096; @@ -74,23 +74,36 @@ private static final String UTF_16LE = "UTF-16LE"; + private static final String UTF_32BE = "UTF-32BE"; + + private static final String UTF_32LE = "UTF-32LE"; + private static final String UTF_16 = "UTF-16"; + private static final String UTF_32 = "UTF-32"; + private static final String EBCDIC = "CP1047"; private static final ByteOrderMark[] BOMS = new ByteOrderMark[] { ByteOrderMark.UTF_8, ByteOrderMark.UTF_16BE, - ByteOrderMark.UTF_16LE + ByteOrderMark.UTF_16LE, + ByteOrderMark.UTF_32BE, + ByteOrderMark.UTF_32LE }; + + // UTF_16LE and UTF_32LE have the same two starting BOM bytes. private static final ByteOrderMark[] XML_GUESS_BYTES = new ByteOrderMark[] { new ByteOrderMark(UTF_8, 0x3C, 0x3F, 0x78, 0x6D), new ByteOrderMark(UTF_16BE, 0x00, 0x3C, 0x00, 0x3F), new ByteOrderMark(UTF_16LE, 0x3C, 0x00, 0x3F, 0x00), + new ByteOrderMark(UTF_32BE, 0x00, 0x00, 0x00, 0x3C, + 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x6D), + new ByteOrderMark(UTF_32LE, 0x3C, 0x00, 0x00, 0x00, + 0x3F, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x6D, 0x00, 0x00, 0x00), new ByteOrderMark(EBCDIC, 0x4C, 0x6F, 0xA7, 0x94) }; - private final Reader reader; private final String encoding; @@ -477,7 +490,7 @@ encoding = ex.getContentTypeEncoding(); } if (encoding == null) { - encoding = (defaultEncoding == null) ? UTF_8 : defaultEncoding; + encoding = defaultEncoding == null ? UTF_8 : defaultEncoding; } return encoding; } @@ -497,7 +510,7 @@ // BOM is Null if (bomEnc == null) { if (xmlGuessEnc == null || xmlEnc == null) { - return (defaultEncoding == null ? UTF_8 : defaultEncoding); + return defaultEncoding == null ? UTF_8 : defaultEncoding; } if (xmlEnc.equals(UTF_16) && (xmlGuessEnc.equals(UTF_16BE) || xmlGuessEnc.equals(UTF_16LE))) { @@ -532,6 +545,19 @@ return bomEnc; } + // BOM is UTF-32BE or UTF-32LE + if (bomEnc.equals(UTF_32BE) || bomEnc.equals(UTF_32LE)) { + if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) { + String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc }); + throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc); + } + if (xmlEnc != null && !xmlEnc.equals(UTF_32) && !xmlEnc.equals(bomEnc)) { + String msg = MessageFormat.format(RAW_EX_1, new Object[] { bomEnc, xmlGuessEnc, xmlEnc }); + throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc); + } + return bomEnc; + } + // BOM is something else String msg = MessageFormat.format(RAW_EX_2, new Object[] { bomEnc, xmlGuessEnc, xmlEnc }); throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc); @@ -576,7 +602,7 @@ if (appXml) { return calculateRawEncoding(bomEnc, xmlGuessEnc, xmlEnc); } else { - return (defaultEncoding == null) ? US_ASCII : defaultEncoding; + return defaultEncoding == null ? US_ASCII : defaultEncoding; } } @@ -598,6 +624,24 @@ throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc); } + // UTF-32BE or UTF-132E content type encoding + if (cTEnc.equals(UTF_32BE) || cTEnc.equals(UTF_32LE)) { + if (bomEnc != null) { + String msg = MessageFormat.format(HTTP_EX_1, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc); + throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc); + } + return cTEnc; + } + + // UTF-32 content type encoding + if (cTEnc.equals(UTF_32)) { + if (bomEnc != null && bomEnc.startsWith(UTF_32)) { + return bomEnc; + } + String msg = MessageFormat.format(HTTP_EX_2, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc); + throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc); + } + return cTEnc; } @@ -629,7 +673,7 @@ * httpContentType is NULL. * * @param httpContentType the HTTP content type - * @return The content type encoding + * @return The content type encoding (upcased) */ static String getContentTypeEncoding(String httpContentType) { String encoding = null; @@ -638,8 +682,8 @@ if (i > -1) { String postMime = httpContentType.substring(i + 1); Matcher m = CHARSET_PATTERN.matcher(postMime); - encoding = (m.find()) ? m.group(1) : null; - encoding = (encoding != null) ? encoding.toUpperCase() : null; + encoding = m.find() ? m.group(1) : null; + encoding = encoding != null ? encoding.toUpperCase(Locale.US) : null; } } return encoding; @@ -717,7 +761,7 @@ (mime.equals("application/xml") || mime.equals("application/xml-dtd") || mime.equals("application/xml-external-parsed-entity") || - (mime.startsWith("application/") && mime.endsWith("+xml"))); + mime.startsWith("application/") && mime.endsWith("+xml")); } /** @@ -731,7 +775,7 @@ return mime != null && (mime.equals("text/xml") || mime.equals("text/xml-external-parsed-entity") || - (mime.startsWith("text/") && mime.endsWith("+xml"))); + mime.startsWith("text/") && mime.endsWith("+xml")); } private static final String RAW_EX_1 = Index: 3rdParty_sources/commons-io/org/apache/commons/io/input/XmlStreamReaderException.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/input/XmlStreamReaderException.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/input/XmlStreamReaderException.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/input/XmlStreamReaderException.java 1 Aug 2014 09:13:48 -0000 1.1.2.1 @@ -28,9 +28,8 @@ * InputStream given to the XmlStreamReader cannot be used as that one has been * already read. * - * @author Alejandro Abdelnur * @version $Id$ - * @since Commons IO 2.0 + * @since 2.0 */ public class XmlStreamReaderException extends IOException { Index: 3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileAlterationListener.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileAlterationListener.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileAlterationListener.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileAlterationListener.java 1 Aug 2014 09:13:51 -0000 1.1.2.1 @@ -24,7 +24,7 @@ * * @see FileAlterationObserver * @version $Id$ - * @since Commons IO 2.0 + * @since 2.0 */ public interface FileAlterationListener { Index: 3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileAlterationListenerAdaptor.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileAlterationListenerAdaptor.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileAlterationListenerAdaptor.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileAlterationListenerAdaptor.java 1 Aug 2014 09:13:51 -0000 1.1.2.1 @@ -23,70 +23,70 @@ * * @see FileAlterationObserver * @version $Id$ - * @since Commons IO 2.0 + * @since 2.0 */ public class FileAlterationListenerAdaptor implements FileAlterationListener { /** * File system observer started checking event. * - * @param observer The file system observer + * @param observer The file system observer (ignored) */ public void onStart(final FileAlterationObserver observer) { } /** * Directory created Event. * - * @param directory The directory created + * @param directory The directory created (ignored) */ public void onDirectoryCreate(final File directory) { } /** * Directory changed Event. * - * @param directory The directory changed + * @param directory The directory changed (ignored) */ public void onDirectoryChange(final File directory) { } /** * Directory deleted Event. * - * @param directory The directory deleted + * @param directory The directory deleted (ignored) */ public void onDirectoryDelete(final File directory) { } /** * File created Event. * - * @param file The file created + * @param file The file created (ignored) */ public void onFileCreate(final File file) { } /** * File changed Event. * - * @param file The file changed + * @param file The file changed (ignored) */ public void onFileChange(final File file) { } /** * File deleted Event. * - * @param file The file deleted + * @param file The file deleted (ignored) */ public void onFileDelete(final File file) { } /** * File system observer finished checking event. * - * @param observer The file system observer + * @param observer The file system observer (ignored) */ public void onStop(final FileAlterationObserver observer) { } Index: 3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileAlterationMonitor.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileAlterationMonitor.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileAlterationMonitor.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileAlterationMonitor.java 1 Aug 2014 09:13:51 -0000 1.1.2.1 @@ -26,7 +26,7 @@ * * @see FileAlterationObserver * @version $Id$ - * @since Commons IO 2.0 + * @since 2.0 */ public final class FileAlterationMonitor implements Runnable { @@ -156,7 +156,7 @@ * @param stopInterval the amount of time in milliseconds to wait for the thread to finish. * A value of zero will wait until the thread is finished (see {@link Thread#join(long)}). * @throws Exception if an error occurs initializing the observer - * @since Commons IO 2.1 + * @since 2.1 */ public synchronized void stop(long stopInterval) throws Exception { if (running == false) { Index: 3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileAlterationObserver.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileAlterationObserver.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileAlterationObserver.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileAlterationObserver.java 1 Aug 2014 09:13:51 -0000 1.1.2.1 @@ -117,7 +117,7 @@ * @see FileAlterationListener * @see FileAlterationMonitor * @version $Id$ - * @since Commons IO 2.0 + * @since 2.0 */ public class FileAlterationObserver implements Serializable { @@ -227,7 +227,7 @@ * Return the fileFilter. * * @return the fileFilter - * @since Commons IO 2.1 + * @since 2.1 */ public FileFilter getFileFilter() { return fileFilter; @@ -428,7 +428,7 @@ private File[] listFiles(File file) { File[] children = null; if (file.isDirectory()) { - children = (fileFilter == null) ? file.listFiles() : file.listFiles(fileFilter); + children = fileFilter == null ? file.listFiles() : file.listFiles(fileFilter); } if (children == null) { children = FileUtils.EMPTY_FILE_ARRAY; Index: 3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileEntry.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileEntry.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileEntry.java 1 Oct 2012 13:03:01 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/monitor/FileEntry.java 1 Aug 2014 09:13:51 -0000 1.1.2.1 @@ -37,7 +37,7 @@ * {@link #newChildInstance(File)} to return a new instance of the appropriate type. * You may also want to override the {@link #refresh(File)} method. * @see FileAlterationObserver - * @since Commons IO 2.0 + * @since 2.0 */ public class FileEntry implements Serializable { @@ -88,7 +88,7 @@ * and length properties are compared for changes * * @param file the file instance to compare to - * @return true if the file has changed, otherwise false + * @return {@code true} if the file has changed, otherwise {@code false} */ public boolean refresh(File file) { @@ -101,15 +101,15 @@ // refresh the values name = file.getName(); exists = file.exists(); - directory = (exists ? file.isDirectory() : false); - lastModified = (exists ? file.lastModified() : 0); - length = (exists && !directory ? file.length() : 0); + directory = exists ? file.isDirectory() : false; + lastModified = exists ? file.lastModified() : 0; + length = exists && !directory ? file.length() : 0; // Return if there are changes - return (exists != origExists || + return exists != origExists || lastModified != origLastModified || directory != origDirectory || - length != origLength); + length != origLength; } /** Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/BrokenOutputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/BrokenOutputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/BrokenOutputStream.java 1 Oct 2012 13:02:59 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/BrokenOutputStream.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -26,7 +26,7 @@ * This class is mostly useful for testing error handling in code that uses an * output stream. * - * @since Commons IO 2.0 + * @since 2.0 */ public class BrokenOutputStream extends OutputStream { Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/ByteArrayOutputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/ByteArrayOutputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/ByteArrayOutputStream.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/ByteArrayOutputStream.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -49,8 +49,6 @@ * designed to behave exactly like the original. The only exception is the * deprecated toString(int) method that has been ignored. * - * @author Jeremias Maerki - * @author Holger Hoffstatte * @version $Id$ */ public class ByteArrayOutputStream extends OutputStream { @@ -184,7 +182,7 @@ * @return total number of bytes read from the input stream * (and written to this stream) * @throws IOException if an I/O error occurs while reading the input stream - * @since Commons IO 1.4 + * @since 1.4 */ public synchronized int write(InputStream in) throws IOException { int readCount = 0; @@ -273,7 +271,7 @@ * @param input Stream to be fully buffered. * @return A fully buffered stream. * @throws IOException if an I/O error occurs - * @since Commons IO 2.0 + * @since 2.0 */ public static InputStream toBufferedInputStream(InputStream input) throws IOException { @@ -290,7 +288,7 @@ * @return the current contents of this output stream. * @see java.io.ByteArrayOutputStream#toByteArray() * @see #reset() - * @since Commons IO 2.0 + * @since 2.0 */ private InputStream toBufferedInputStream() { int remaining = count; Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/CloseShieldOutputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/CloseShieldOutputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/CloseShieldOutputStream.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/CloseShieldOutputStream.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -26,7 +26,7 @@ * other components would still use the stream for output. * * @version $Id$ - * @since Commons IO 1.4 + * @since 1.4 */ public class CloseShieldOutputStream extends ProxyOutputStream { Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/ClosedOutputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/ClosedOutputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/ClosedOutputStream.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/ClosedOutputStream.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -25,10 +25,10 @@ *

    * Typically uses of this class include testing for corner cases in methods * that accept an output stream and acting as a sentinel value instead of - * a null output stream. + * a {@code null} output stream. * * @version $Id$ - * @since Commons IO 1.4 + * @since 1.4 */ public class ClosedOutputStream extends OutputStream { Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/CountingOutputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/CountingOutputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/CountingOutputStream.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/CountingOutputStream.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -47,7 +47,7 @@ * Updates the count with the number of bytes that are being written. * * @param n number of bytes to be written to the stream - * @since Commons IO 2.0 + * @since 2.0 */ @Override protected synchronized void beforeWrite(int n) { @@ -99,7 +99,7 @@ * result in incorrect count for files over 2GB. * * @return the number of bytes accumulated - * @since Commons IO 1.3 + * @since 1.3 */ public synchronized long getByteCount() { return this.count; @@ -113,7 +113,7 @@ * result in incorrect count for files over 2GB. * * @return the count previous to resetting - * @since Commons IO 1.3 + * @since 1.3 */ public synchronized long resetByteCount() { long tmp = this.count; Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/DeferredFileOutputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/DeferredFileOutputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/DeferredFileOutputStream.java 1 Oct 2012 13:02:59 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/DeferredFileOutputStream.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -36,9 +36,6 @@ * you want to store it in memory (for speed), but if the file is large you want * to store it to file (to avoid memory issues). * - * @author Martin Cooper - * @author gaxzerow - * * @version $Id$ */ public class DeferredFileOutputStream @@ -114,11 +111,11 @@ * @param suffix Suffix to use for the temporary file. * @param directory Temporary file directory. * - * @since Commons IO 1.4 + * @since 1.4 */ public DeferredFileOutputStream(int threshold, String prefix, String suffix, File directory) { - this(threshold, null, prefix, suffix, directory); + this(threshold, null, prefix, suffix, directory); if (prefix == null) { throw new IllegalArgumentException("Temporary file prefix is missing"); } @@ -192,21 +189,21 @@ * Determines whether or not the data for this output stream has been * retained in memory. * - * @return true if the data is available in memory; - * false otherwise. + * @return {@code true} if the data is available in memory; + * {@code false} otherwise. */ public boolean isInMemory() { - return (!isThresholdExceeded()); + return !isThresholdExceeded(); } /** * Returns the data for this output stream as an array of bytes, assuming * that the data has been retained in memory. If the data was written to - * disk, this method returns null. + * disk, this method returns {@code null}. * - * @return The data for this output stream, or null if no such + * @return The data for this output stream, or {@code null} if no such * data is available. */ public byte[] getData() @@ -224,13 +221,13 @@ * the temporary file created or null. *

    * If the constructor specifying the file is used then it returns that - * same output file, even when threashold has not been reached. + * same output file, even when threshold has not been reached. *

    * If constructor specifying a temporary file prefix/suffix is used - * then the temporary file created once the threashold is reached is returned - * If the threshold was not reached then null is returned. + * then the temporary file created once the threshold is reached is returned + * If the threshold was not reached then {@code null} is returned. * - * @return The file for this output stream, or null if no such + * @return The file for this output stream, or {@code null} if no such * file exists. */ public File getFile() Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/DemuxOutputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/DemuxOutputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/DemuxOutputStream.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/DemuxOutputStream.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -23,8 +23,7 @@ * Data written to this stream is forwarded to a stream that has been associated * with this thread. * - * @author Peter Donald - * @version $Revision$ $Date$ + * @version $Id$ */ public class DemuxOutputStream extends OutputStream Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/FileWriterWithEncoding.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/FileWriterWithEncoding.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/FileWriterWithEncoding.java 1 Oct 2012 13:02:59 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/FileWriterWithEncoding.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -44,7 +44,7 @@ *

    * * - * @since Commons IO 1.4 + * @since 1.4 * @version $Id$ */ public class FileWriterWithEncoding extends Writer { Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/LockableFileWriter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/LockableFileWriter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/LockableFileWriter.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/LockableFileWriter.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -18,12 +18,15 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.FileWriter; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; +import java.io.UnsupportedEncodingException; import java.io.Writer; +import java.nio.charset.Charset; +import java.nio.charset.UnsupportedCharsetException; +import org.apache.commons.io.Charsets; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; @@ -45,12 +48,6 @@ * java.io.tmpdir. * The encoding may also be specified, and defaults to the platform default. * - * @author Scott Sanders - * @author Michael Salmon - * @author Jon S. Stevens - * @author Daniel Rall - * @author Stephen Colebourne - * @author Andy Lehane * @version $Id$ */ public class LockableFileWriter extends Writer { @@ -136,7 +133,7 @@ * @throws IOException in case of an I/O error */ public LockableFileWriter(File file, boolean append, String lockDir) throws IOException { - this(file, null, append, lockDir); + this(file, Charset.defaultCharset(), append, lockDir); } /** @@ -146,7 +143,23 @@ * @param encoding the encoding to use, null means platform default * @throws NullPointerException if the file is null * @throws IOException in case of an I/O error + * @since 2.3 */ + public LockableFileWriter(File file, Charset encoding) throws IOException { + this(file, encoding, false, null); + } + + /** + * Constructs a LockableFileWriter with a file encoding. + * + * @param file the file to write to, not null + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if the file is null + * @throws IOException in case of an I/O error + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + */ public LockableFileWriter(File file, String encoding) throws IOException { this(file, encoding, false, null); } @@ -160,8 +173,9 @@ * @param lockDir the directory in which the lock file should be held * @throws NullPointerException if the file is null * @throws IOException in case of an I/O error + * @since 2.3 */ - public LockableFileWriter(File file, String encoding, boolean append, + public LockableFileWriter(File file, Charset encoding, boolean append, String lockDir) throws IOException { super(); // init file to create/append @@ -189,6 +203,24 @@ out = initWriter(file, encoding, append); } + /** + * Constructs a LockableFileWriter with a file encoding. + * + * @param file the file to write to, not null + * @param encoding the encoding to use, null means platform default + * @param append true if content should be appended, false to overwrite + * @param lockDir the directory in which the lock file should be held + * @throws NullPointerException if the file is null + * @throws IOException in case of an I/O error + * @throws UnsupportedCharsetException + * thrown instead of {@link UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + */ + public LockableFileWriter(File file, String encoding, boolean append, + String lockDir) throws IOException { + this(file, Charsets.toCharset(encoding), append, lockDir); + } + //----------------------------------------------------------------------- /** * Tests that we can write to the lock directory. @@ -233,17 +265,13 @@ * @return The initialised writer * @throws IOException if an error occurs */ - private Writer initWriter(File file, String encoding, boolean append) throws IOException { + private Writer initWriter(File file, Charset encoding, boolean append) throws IOException { boolean fileExistedAlready = file.exists(); OutputStream stream = null; Writer writer = null; try { - if (encoding == null) { - writer = new FileWriter(file.getAbsolutePath(), append); - } else { - stream = new FileOutputStream(file.getAbsolutePath(), append); - writer = new OutputStreamWriter(stream, encoding); - } + stream = new FileOutputStream(file.getAbsolutePath(), append); + writer = new OutputStreamWriter(stream, Charsets.toCharset(encoding)); } catch (IOException ex) { IOUtils.closeQuietly(writer); IOUtils.closeQuietly(stream); Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/NullOutputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/NullOutputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/NullOutputStream.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/NullOutputStream.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -25,7 +25,6 @@ * This output stream has no destination (file/socket etc.) and all * bytes written to it are ignored and lost. * - * @author Jeremias Maerki * @version $Id$ */ public class NullOutputStream extends OutputStream { Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/NullWriter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/NullWriter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/NullWriter.java 1 Oct 2012 13:02:59 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/NullWriter.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -43,7 +43,7 @@ * Does nothing - output to /dev/null. * @param c The character to write * @return this writer - * @since Commons IO 2.0 + * @since 2.0 */ @Override public Writer append(char c) { @@ -57,7 +57,7 @@ * @param start The index of the first character to write * @param end The index of the first character to write (exclusive) * @return this writer - * @since Commons IO 2.0 + * @since 2.0 */ @Override public Writer append(CharSequence csq, int start, int end) { @@ -69,7 +69,7 @@ * Does nothing - output to /dev/null. * @param csq The character sequence to write * @return this writer - * @since Commons IO 2.0 + * @since 2.0 */ @Override public Writer append(CharSequence csq) { Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/ProxyOutputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/ProxyOutputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/ProxyOutputStream.java 1 Oct 2012 13:02:59 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/ProxyOutputStream.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -29,7 +29,6 @@ * See the protected methods for ways in which a subclass can easily decorate * a stream with custom pre-, post- or error processing functionality. * - * @author Stephen Colebourne * @version $Id$ */ public class ProxyOutputStream extends FilterOutputStream { @@ -130,7 +129,7 @@ * functionality without having to override all the write methods. * The default implementation does nothing. * - * @since Commons IO 2.0 + * @since 2.0 * @param n number of bytes to be written * @throws IOException if the pre-processing fails */ @@ -147,7 +146,7 @@ * functionality without having to override all the write methods. * The default implementation does nothing. * - * @since Commons IO 2.0 + * @since 2.0 * @param n number of bytes written * @throws IOException if the post-processing fails */ @@ -161,7 +160,7 @@ * handling. The default behaviour is to re-throw the exception. * @param e The IOException thrown * @throws IOException if an I/O error occurs - * @since Commons IO 2.0 + * @since 2.0 */ protected void handleIOException(IOException e) throws IOException { throw e; Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/ProxyWriter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/ProxyWriter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/ProxyWriter.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/ProxyWriter.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -28,7 +28,6 @@ * methods being called, such as write(char[]) to write(char[], int, int) * and write(String) to write(String, int, int). * - * @author Stephen Colebourne * @version $Id$ */ public class ProxyWriter extends FilterWriter { @@ -48,7 +47,7 @@ * @param c The character to write * @return this writer * @throws IOException if an I/O error occurs - * @since Commons IO 2.0 + * @since 2.0 */ @Override public Writer append(char c) throws IOException { @@ -69,7 +68,7 @@ * @param end The index of the first character to write (exclusive) * @return this writer * @throws IOException if an I/O error occurs - * @since Commons IO 2.0 + * @since 2.0 */ @Override public Writer append(CharSequence csq, int start, int end) throws IOException { @@ -88,7 +87,7 @@ * @param csq The character sequence to write * @return this writer * @throws IOException if an I/O error occurs - * @since Commons IO 2.0 + * @since 2.0 */ @Override public Writer append(CharSequence csq) throws IOException { @@ -236,7 +235,7 @@ * functionality without having to override all the write methods. * The default implementation does nothing. * - * @since Commons IO 2.0 + * @since 2.0 * @param n number of chars to be written * @throws IOException if the pre-processing fails */ @@ -253,7 +252,7 @@ * functionality without having to override all the write methods. * The default implementation does nothing. * - * @since Commons IO 2.0 + * @since 2.0 * @param n number of chars written * @throws IOException if the post-processing fails */ @@ -267,7 +266,7 @@ * handling. The default behaviour is to re-throw the exception. * @param e The IOException thrown * @throws IOException if an I/O error occurs - * @since Commons IO 2.0 + * @since 2.0 */ protected void handleIOException(IOException e) throws IOException { throw e; Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/StringBuilderWriter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/StringBuilderWriter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/StringBuilderWriter.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/StringBuilderWriter.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -28,8 +28,8 @@ * For safe usage with multiple {@link Thread}s then * java.io.StringWriter should be used. * - * @version $Revision$ $Date$ - * @since Commons IO 2.0 + * @version $Id$ + * @since 2.0 */ public class StringBuilderWriter extends Writer implements Serializable { @@ -57,7 +57,7 @@ * @param builder The String builder */ public StringBuilderWriter(StringBuilder builder) { - this.builder = (builder != null ? builder : new StringBuilder()); + this.builder = builder != null ? builder : new StringBuilder(); } /** Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/TaggedOutputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/TaggedOutputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/TaggedOutputStream.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/TaggedOutputStream.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -59,7 +59,7 @@ * * * @see TaggedIOException - * @since Commons IO 2.0 + * @since 2.0 */ public class TaggedOutputStream extends ProxyOutputStream { @@ -81,8 +81,8 @@ * Tests if the given exception was caused by this stream. * * @param exception an exception - * @return true if the exception was thrown by this stream, - * false otherwise + * @return {@code true} if the exception was thrown by this stream, + * {@code false} otherwise */ public boolean isCauseOf(Exception exception) { return TaggedIOException.isTaggedWith(exception, tag); Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/TeeOutputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/TeeOutputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/TeeOutputStream.java 1 Oct 2012 13:02:59 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/TeeOutputStream.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -36,7 +36,7 @@ * @param out the main OutputStream * @param branch the second OutputStream */ - public TeeOutputStream( OutputStream out, OutputStream branch ) { + public TeeOutputStream(OutputStream out, OutputStream branch) { super(out); this.branch = branch; } @@ -87,13 +87,23 @@ } /** - * Closes both streams. - * @throws IOException if an I/O error occurs + * Closes both output streams. + * + * If closing the main output stream throws an exception, attempt to close the branch output stream. + * + * If closing the main and branch output streams both throw exceptions, which exceptions is thrown by this method is + * currently unspecified and subject to change. + * + * @throws IOException + * if an I/O error occurs */ @Override public void close() throws IOException { - super.close(); - this.branch.close(); + try { + super.close(); + } finally { + this.branch.close(); + } } } Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/ThresholdingOutputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/ThresholdingOutputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/ThresholdingOutputStream.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/ThresholdingOutputStream.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -34,8 +34,6 @@ * is actually reached, since it triggers when a pending write operation would * cause the threshold to be exceeded. * - * @author Martin Cooper - * * @version $Id$ */ public abstract class ThresholdingOutputStream @@ -196,12 +194,12 @@ * Determines whether or not the configured threshold has been exceeded for * this output stream. * - * @return true if the threshold has been reached; - * false otherwise. + * @return {@code true} if the threshold has been reached; + * {@code false} otherwise. */ public boolean isThresholdExceeded() { - return (written > threshold); + return written > threshold; } @@ -220,7 +218,7 @@ */ protected void checkThreshold(int count) throws IOException { - if (!thresholdExceeded && (written + count > threshold)) + if (!thresholdExceeded && written + count > threshold) { thresholdExceeded = true; thresholdReached(); Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/WriterOutputStream.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/WriterOutputStream.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/WriterOutputStream.java 1 Oct 2012 13:02:59 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/WriterOutputStream.java 1 Aug 2014 09:13:50 -0000 1.1.2.1 @@ -68,8 +68,7 @@ * * @see org.apache.commons.io.input.ReaderInputStream * - * @author Andreas Veithen - * @since Commons IO 2.0 + * @since 2.0 */ public class WriterOutputStream extends OutputStream { private static final int DEFAULT_BUFFER_SIZE = 1024; @@ -99,7 +98,7 @@ * * @param writer the target {@link Writer} * @param decoder the charset decoder - * @since Commons IO 2.1 + * @since 2.1 */ public WriterOutputStream(Writer writer, CharsetDecoder decoder) { this(writer, decoder, DEFAULT_BUFFER_SIZE, false); @@ -116,7 +115,7 @@ * underlying {@link Writer} immediately. If false, the * output buffer will only be flushed when it overflows or when * {@link #flush()} or {@link #close()} is called. - * @since Commons IO 2.1 + * @since 2.1 */ public WriterOutputStream(Writer writer, CharsetDecoder decoder, int bufferSize, boolean writeImmediately) { this.writer = writer; Index: 3rdParty_sources/commons-io/org/apache/commons/io/output/XmlStreamWriter.java =================================================================== RCS file: /usr/local/cvsroot/3rdParty_sources/commons-io/org/apache/commons/io/output/XmlStreamWriter.java,v diff -u -r1.1 -r1.1.2.1 --- 3rdParty_sources/commons-io/org/apache/commons/io/output/XmlStreamWriter.java 1 Oct 2012 13:03:00 -0000 1.1 +++ 3rdParty_sources/commons-io/org/apache/commons/io/output/XmlStreamWriter.java 1 Aug 2014 09:13:49 -0000 1.1.2.1 @@ -33,10 +33,9 @@ * Character stream that handles all the necessary Voodo to figure out the * charset encoding of the XML document written to the stream. * - * @author Herve Boutemy * @version $Id$ * @see XmlStreamReader - * @since Commons IO 2.0 + * @since 2.0 */ public class XmlStreamWriter extends Writer { private static final int BUFFER_SIZE = 4096; @@ -70,7 +69,7 @@ */ public XmlStreamWriter(OutputStream out, String defaultEncoding) { this.out = out; - this.defaultEncoding = (defaultEncoding != null ? defaultEncoding : "UTF-8"); + this.defaultEncoding = defaultEncoding != null ? defaultEncoding : "UTF-8"; } /** Index: lams_build/3rdParty.userlibraries =================================================================== RCS file: /usr/local/cvsroot/lams_build/3rdParty.userlibraries,v diff -u -r1.71.2.4 -r1.71.2.5 --- lams_build/3rdParty.userlibraries 1 Aug 2014 09:01:44 -0000 1.71.2.4 +++ lams_build/3rdParty.userlibraries 1 Aug 2014 09:13:44 -0000 1.71.2.5 @@ -12,7 +12,6 @@ - Index: lams_build/build_base.xml =================================================================== RCS file: /usr/local/cvsroot/lams_build/build_base.xml,v diff -u -r1.25.2.4 -r1.25.2.5 --- lams_build/build_base.xml 1 Aug 2014 08:59:21 -0000 1.25.2.4 +++ lams_build/build_base.xml 1 Aug 2014 09:13:44 -0000 1.25.2.5 @@ -41,7 +41,7 @@ - + Index: lams_build/liblist.txt =================================================================== RCS file: /usr/local/cvsroot/lams_build/liblist.txt,v diff -u -r1.25.2.4 -r1.25.2.5 --- lams_build/liblist.txt 1 Aug 2014 08:59:21 -0000 1.25.2.4 +++ lams_build/liblist.txt 1 Aug 2014 09:13:44 -0000 1.25.2.5 @@ -30,11 +30,9 @@ translate.jar jakarta-commons commons-codec-1.3.jar 1.3 Apache License 2.0 Apache Software Foundation Jakarta Commons Codec - commons-digester.jar 1.6 Apache License 2.0 Apache Software Foundation Jakarta Commons Digester commons-discovery-0.2.jar 0.2 Apache Software License 1.1 Apache Software Foundation commons-fileupload.jar 1.0 Apache Software License 1.1 Apache Software Foundation File upload component for Java servlets commons-httpclient-3.0.jar 3.0 Apache License 2.0 Apache Software Foundation HTTP tools - commons-io-2.1.jar 2.1 Apache License 2.0 Apache Software Foundation Apache Commons IO commons-lang.jar 2.6 Apache Software License 1.1 Apache Software Foundation Jakarta Commons Lang commons-logging.jar 1.0.4 Apache License 2.0 Apache Software Foundation commons-validator.jar 1.1.4 Apache License 2.0 The Apache Software Foundation Commons Validator Index: lams_build/conf/j2ee/jboss-deployment-structure.xml =================================================================== RCS file: /usr/local/cvsroot/lams_build/conf/j2ee/Attic/jboss-deployment-structure.xml,v diff -u -r1.1.2.1 -r1.1.2.2 --- lams_build/conf/j2ee/jboss-deployment-structure.xml 1 Aug 2014 08:59:22 -0000 1.1.2.1 +++ lams_build/conf/j2ee/jboss-deployment-structure.xml 1 Aug 2014 09:13:44 -0000 1.1.2.2 @@ -26,6 +26,7 @@ +