From: <jrb...@us...> - 2009-07-22 20:20:01
|
Revision: 894 http://cishell.svn.sourceforge.net/cishell/?rev=894&view=rev Author: jrbibers Date: 2009-07-22 20:19:56 +0000 (Wed, 22 Jul 2009) Log Message: ----------- Added method to test whether a File is empty to FileUtilities. Modified Paths: -------------- trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java Modified: trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java =================================================================== --- trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java 2009-07-21 13:07:46 UTC (rev 893) +++ trunk/core/org.cishell.utilities/src/org/cishell/utilities/FileUtilities.java 2009-07-22 20:19:56 UTC (rev 894) @@ -1,7 +1,10 @@ package org.cishell.utilities; import java.awt.image.BufferedImage; +import java.io.BufferedReader; import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; @@ -131,6 +134,15 @@ return temporaryTextFile; } + public static boolean isFileEmpty(File file) + throws FileNotFoundException, IOException { + final BufferedReader reader = new BufferedReader(new FileReader(file)); + String firstLine = reader.readLine(); + reader.close(); + boolean fileIsEmpty = ( firstLine == null ); + return fileIsEmpty; + } + private static File ensureDirectoryExists(String directoryPath) { File directory = new File(directoryPath); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |