com.cometway.io
Class FileTools

java.lang.Object
  extended by com.cometway.io.FileTools

public abstract class FileTools
extends java.lang.Object

A utility class for common file related operations.


Constructor Summary
FileTools()
           
 
Method Summary
static java.lang.String getFileModifiedString(java.io.File f, java.text.SimpleDateFormat sdf)
          Returns a String describing the modification of the specified File using the specified SimpleDateFormat as a template.
static java.lang.String getFileSizeString(java.io.File f)
          Returns a string describing the size of the specified File.
static void writeFile(java.io.File file, java.io.File tempFile, byte[] filedata)
          Writes the bytes contained in filedata to the specified File.
static void writeFile(java.lang.String filename, byte[] filedata)
          Writes the bytes contained in filedata to the specified file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileTools

public FileTools()
Method Detail

getFileModifiedString

public static java.lang.String getFileModifiedString(java.io.File f,
                                                     java.text.SimpleDateFormat sdf)
Returns a String describing the modification of the specified File using the specified SimpleDateFormat as a template.


getFileSizeString

public static java.lang.String getFileSizeString(java.io.File f)
Returns a string describing the size of the specified File. If the size is less than 1024 bytes, the size is given in bytes. If the size is less then 1024 K bytes, the size is given in K. If the size is 1024 K bytes or more, the size is given in M.


writeFile

public static void writeFile(java.lang.String filename,
                             byte[] filedata)
                      throws FileToolsException
Writes the bytes contained in filedata to the specified file. The file will be written to a temp file (filename + ".temp"). If necessary the file specified by filename will be deleted, before renaming the temp file as filename.

Throws:
FileToolsException

writeFile

public static void writeFile(java.io.File file,
                             java.io.File tempFile,
                             byte[] filedata)
                      throws FileToolsException
Writes the bytes contained in filedata to the specified File. The file will be written to the specified File. If necessary the File specified by file will be deleted, before renaming the tempFile as file.

Throws:
FileToolsException