cvs commit: jakarta-commons-sandbox/io/src/java/org/apache/commons/io FileUtils.java
jeremias2003/12/30 07:24:01 Modified:io/src/java/org/apache/commons/io FileUtils.java Log: Javadocs: Missing parameter description Revision ChangesPath 1.24 +2 -1 jakarta-commons-sandbox/io/src/java/org/apache/commons/io/FileUtils.java Index: FileUtils.java === RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/FileUtils.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- FileUtils.java30 Dec 2003 06:50:16 - 1.23 +++ FileUtils.java30 Dec 2003 15:24:01 - 1.24 @@ -611,6 +611,7 @@ * * @param file the file to write. * @param data The content to write to the file. + * @param encoding encoding to use * @throws IOException in case of an I/O error * @throws UnsupportedEncodingException if the encoding is not supported * by the VM - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons-sandbox/io/src/java/org/apache/commons/io FileUtils.java
jeremias2003/12/30 08:27:42 Modified:io/src/java/org/apache/commons/io FileUtils.java Log: Made convertFileCollectionToFileArray static. Revision ChangesPath 1.25 +2 -2 jakarta-commons-sandbox/io/src/java/org/apache/commons/io/FileUtils.java Index: FileUtils.java === RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/FileUtils.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- FileUtils.java30 Dec 2003 15:24:01 - 1.24 +++ FileUtils.java30 Dec 2003 16:27:42 - 1.25 @@ -192,7 +192,7 @@ * @param files a Collection containing java.io.File instances * @return an array of java.io.File */ -public File[] convertFileCollectionToFileArray(Collection files) { +public static File[] convertFileCollectionToFileArray(Collection files) { return (File[])files.toArray(new File[files.size()]); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons-sandbox/io/src/java/org/apache/commons/io FileUtils.java
bayard 2003/12/29 05:14:52 Modified:io/src/java/org/apache/commons/io FileUtils.java Log: made toSuffixes private as it is a helper method to another method Revision ChangesPath 1.22 +2 -2 jakarta-commons-sandbox/io/src/java/org/apache/commons/io/FileUtils.java Index: FileUtils.java === RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/FileUtils.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- FileUtils.java29 Dec 2003 03:28:53 - 1.21 +++ FileUtils.java29 Dec 2003 13:14:52 - 1.22 @@ -257,7 +257,7 @@ * @param extensions an array of extensions. Format: {java, xml} * @return an array of suffixes. Format: {.java, .xml} */ -public static String[] toSuffixes(final String[] extensions) { +private static String[] toSuffixes(final String[] extensions) { String[] suffixes = new String[extensions.length]; for (int i = 0; i extensions.length; i++) { suffixes[i] = . + extensions[i]; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons-sandbox/io/src/java/org/apache/commons/io FileUtils.java
jeremias2003/12/25 03:05:59 Modified:io/src/java/org/apache/commons/io FileUtils.java Log: BugZilla #25742: Change listFiles so its behaviour matches the javadocs. Fixes NPE when extension is null. Submitted by: Ignat Skoryh ignat.at.tiger.unisquad.com Revision ChangesPath 1.20 +8 -3 jakarta-commons-sandbox/io/src/java/org/apache/commons/io/FileUtils.java Index: FileUtils.java === RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/FileUtils.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- FileUtils.java23 Nov 2003 20:43:30 - 1.19 +++ FileUtils.java25 Dec 2003 11:05:59 - 1.20 @@ -276,8 +276,13 @@ * @return an collection of java.io.File with the matching files */ public static Collection listFiles(File directory, String[] extensions, boolean recursive) { -String[] suffixes = toSuffixes(extensions); -IOFileFilter filter = new SuffixFileFilter(suffixes); +IOFileFilter filter; +if (extensions == null) { +filter = TrueFileFilter.INSTANCE; +} else { +String[] suffixes = toSuffixes(extensions); +filter = new SuffixFileFilter(suffixes); +} return listFiles(directory, filter, (recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE)); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cvs commit: jakarta-commons-sandbox/io/src/java/org/apache/commons/io FileUtils.java
I forgot to credit Alban Peignier alban.peignier at free.fr for his isFileNewer methods. I'm sorry. I shouldn't do more than a couple of things at once. http://nagoya.apache.org/eyebrowse/[EMAIL PROTECTED]by=threadfrom=348688 On 21.08.2003 20:40:48 jeremias wrote: jeremias2003/08/21 11:40:48 Modified:io/src/java/org/apache/commons/io FileUtils.java snip/ Index: FileUtils.java === RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/FileUtils.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 snip/ + /** + * Tests if the specified codeFile/code is newer than the reference + * codeFile/code. + * + * @param file the codeFile/code of which the modification date must be compared + * @param reference the codeFile/code of which the modification date is used + * like reference + * @return true if the codeFile/code exists and has been modified more recently + * than the reference codeFile/code. + */ + public static boolean isFileNewer(final File file, final File reference) { + if (reference == null) { + throw new IllegalArgumentException(No specified reference file); + } + if (!reference.exists()) { + throw new IllegalArgumentException(The reference file ' + file + ' doesn't exist); + } + + return isFileNewer(file, reference.lastModified()); + } + + /** + * Tests if the specified codeFile/code is newer than the specified + * codeDate/code + * + * @param file the codeFile/code of which the modification date must be compared + * @param date the date reference + * @return true if the codeFile/code exists and has been modified after + * the given codeDate/code. + */ + public static boolean isFileNewer(final File file, final Date date) { + if (date == null) { + throw new IllegalArgumentException(No specified date); + } + return isFileNewer(file, date.getTime()); + } + + /** + * Tests if the specified codeFile/code is newer than the specified + * time reference. + * + * @param file the codeFile/code of which the modification date must be compared. + * @param timeMillis the time reference measured in milliseconds since the epoch + * (00:00:00 GMT, January 1, 1970) + * @return true if the codeFile/code exists and has been modified after + * the given time reference. + */ + public static boolean isFileNewer(final File file, final long timeMillis) { + if (file == null) { + throw new IllegalArgumentException(No specified file); + } + if (!file.exists()) { + return false; + } + + return file.lastModified() timeMillis; +} Jeremias Maerki - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-commons-sandbox/io/src/java/org/apache/commons/io FileUtils.java IOUtils.java HexDump.java EndianUtils.java
jeremias2003/07/29 06:07:39 Modified:io/src/java/org/apache/commons/io FileUtils.java IOUtils.java HexDump.java EndianUtils.java Log: Remove private constructors because of problems with Velocity which needs an instance (Christoph Reck) some todos. Revision ChangesPath 1.13 +7 -9 jakarta-commons-sandbox/io/src/java/org/apache/commons/io/FileUtils.java Index: FileUtils.java === RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/FileUtils.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- FileUtils.java27 Jul 2003 17:20:23 - 1.12 +++ FileUtils.java29 Jul 2003 13:07:39 - 1.13 @@ -123,14 +123,6 @@ public static final int ONE_GB = ONE_KB * ONE_MB; /** - * Private constructor to prevent instantiation. - * - */ -private FileUtils() -{ -} - -/** * Returns a human-readable version of the file size (original is in * bytes). * @@ -158,6 +150,8 @@ * Matches the equally named unix command. * @param filename filename to inspect * @return The directory portion excluding the ending file separator. + * @deprecated use getPath() instead. + * TODO DELETE before 1.0 */ public static String dirname(String filename) { int i = filename.lastIndexOf(File.separator); @@ -168,6 +162,8 @@ * Returns the filename portion of a file specification string. * @param filename filename to inspect * @return The filename string with extension. + * @deprecated use removeExtension() instead. + * TODO DELETE before 1.0 */ public static String filename(String filename) { int i = filename.lastIndexOf(File.separator); @@ -179,6 +175,7 @@ * Matches the equally named unix command. * @param filename filename to inspect * @return The filename string without extension. + * TODO DELETE before 1.0 */ public static String basename(String filename) { return basename(filename, extension(filename)); @@ -212,6 +209,7 @@ * the dot). * @param filename filename to inspect * @return the extension + * TODO probably duplicate method. See getExtension */ public static String extension(String filename) { int lastDot = filename.lastIndexOf('.'); 1.4 +1 -8 jakarta-commons-sandbox/io/src/java/org/apache/commons/io/IOUtils.java Index: IOUtils.java === RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/IOUtils.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- IOUtils.java 27 Jul 2003 17:21:27 - 1.3 +++ IOUtils.java 29 Jul 2003 13:07:39 - 1.4 @@ -151,13 +151,6 @@ private static final int DEFAULT_BUFFER_SIZE = 1024 * 4; /** - * Private constructor to prevent instantiation. - */ -private IOUtils() -{ -} - -/** * Unconditionally close an codeReader/code. * Equivalent to [EMAIL PROTECTED] Reader#close()}, except any exceptions will be ignored. * 1.3 +4 -8 jakarta-commons-sandbox/io/src/java/org/apache/commons/io/HexDump.java Index: HexDump.java === RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/HexDump.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- HexDump.java 27 Jul 2003 17:20:59 - 1.2 +++ HexDump.java 29 Jul 2003 13:07:39 - 1.3 @@ -74,10 +74,6 @@ */ public class HexDump { -// all static methods, so no need for a public constructor -private HexDump() { -} - /** * dump an array of bytes to an OutputStream * 1.3 +1 -7 jakarta-commons-sandbox/io/src/java/org/apache/commons/io/EndianUtils.java Index: EndianUtils.java === RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/EndianUtils.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- EndianUtils.java 27 Jul 2003 17:18:40 - 1.2 +++ EndianUtils.java 29 Jul 2003 13:07:39 - 1.3 @@ -69,12 +69,6 @@ public final class EndianUtils { -/** - * Private constructor to avoid instantiation. - */ -private EndianUtils() { -} - // == Swapping routines /**
cvs commit: jakarta-commons-sandbox/io/src/java/org/apache/commons/io FileUtils.java
jeremias2003/07/27 10:20:23 Modified:io/src/java/org/apache/commons/io FileUtils.java Log: Javadocs Rewrite some methods to leverage off methods from IOUtils. Added some TODO items (methods not making sense...) Revision ChangesPath 1.12 +86 -41 jakarta-commons-sandbox/io/src/java/org/apache/commons/io/FileUtils.java Index: FileUtils.java === RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/FileUtils.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- FileUtils.java25 Jul 2003 07:51:24 - 1.11 +++ FileUtils.java27 Jul 2003 17:20:23 - 1.12 @@ -61,7 +61,7 @@ import java.net.URL; import java.util.Vector; -/* +/** * This class provides basic facilities for manipulating files and file paths. * * h3Path-related methods/h3 @@ -89,10 +89,13 @@ * /p * * Common [EMAIL PROTECTED] java.io.File} manipulation routines. - * - * Taken from the commons-utils repo. - * Also code from Alexandria's FileUtils. - * And from Avalon Excalibur's IO. + * + * h3Origin of code/h3 + * ul + * licommons-utils repo/li + * liAlexandria's FileUtils./li + * liAvalon Excalibur's IO./li + * /ul * * @author a href=mailto:[EMAIL PROTECTED]Kevin A. Burton/A * @author a href=mailto:[EMAIL PROTECTED]Scott Sanders/a @@ -120,6 +123,14 @@ public static final int ONE_GB = ONE_KB * ONE_MB; /** + * Private constructor to prevent instantiation. + * + */ +private FileUtils() +{ +} + +/** * Returns a human-readable version of the file size (original is in * bytes). * @@ -145,6 +156,7 @@ /** * Returns the directory path portion of a file specification string. * Matches the equally named unix command. + * @param filename filename to inspect * @return The directory portion excluding the ending file separator. */ public static String dirname(String filename) { @@ -154,6 +166,7 @@ /** * Returns the filename portion of a file specification string. + * @param filename filename to inspect * @return The filename string with extension. */ public static String filename(String filename) { @@ -164,6 +177,7 @@ /** * Returns the filename portion of a file specification string. * Matches the equally named unix command. + * @param filename filename to inspect * @return The filename string without extension. */ public static String basename(String filename) { @@ -173,6 +187,10 @@ /** * Returns the filename portion of a file specification string. * Matches the equally named unix command. + * @param filename filename to inspect + * @param suffix additional remaining portion of name that if matches will + * be removed + * @return The filename string without the suffix. */ public static String basename(String filename, String suffix) { int i = filename.lastIndexOf(File.separator) + 1; @@ -192,6 +210,8 @@ * Returns the extension portion of a file specification string. * This everything after the last dot '.' in the filename (NOT including * the dot). + * @param filename filename to inspect + * @return the extension */ public static String extension(String filename) { int lastDot = filename.lastIndexOf('.'); @@ -215,26 +235,22 @@ } /** - * Reads the contents of a file. + * Reads the contents of a file (using the default encoding). * * @param fileName The name of the file to read. * @return The file contents or null if read failed. + * @throws IOException in case of an I/O error + * TODO This method should probably be removed or rethought. + * Because it uses the default encoding only it should probably not be + * used at all (platform-dependency) */ -public static String fileRead(String fileName) throws IOException { -StringBuffer buf = new StringBuffer(); - +public static String fileRead(final String fileName) throws IOException { FileInputStream in = new FileInputStream(fileName); - -int count; -byte[] b = new byte[512]; -while ((count = in.read(b)) 0) // blocking read -{ -buf.append(new String(b, 0, count)); +try { +return IOUtils.toString(in); +} finally { +IOUtils.shutdownStream(in); } - -in.close(); - -return buf.toString(); } /** @@ -242,11 +258,18 @@ * * @param fileName The name of the file to write. *