com.limegroup.gnutella.util
Class FileUtils

java.lang.Object
  extended bycom.limegroup.gnutella.util.FileUtils

public class FileUtils
extends java.lang.Object

This class provides static functions to load/store the files.


Constructor Summary
FileUtils()
           
 
Method Summary
static java.io.File getCanonicalFile(java.io.File f)
          Same as f.getCanonicalFile() in JDK1.3.
static java.lang.String getFileExtension(java.io.File f)
          Utility method that returns the file extension of the given file.
static java.io.File getParentFile(java.io.File f)
          Same as f.getParentFile() in JDK1.3.
static java.io.File[] listFiles(java.io.File f)
          Same as the f.listFiles() in JDK1.3.
static java.io.File[] listFiles(java.io.File f, java.io.FilenameFilter filter)
          Same as f.listFiles(FileNameFilter) in JDK1.2
static java.util.Map readMap(java.lang.String filename)
          Reads the map stored, in serialized object form, in the passed file and returns it.
static boolean setWriteable(java.io.File f)
          Utility method to set a file as non read only.
static void writeMap(java.lang.String filename, java.util.Map map)
          Writes the passed map to corresponding file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtils

public FileUtils()
Method Detail

writeMap

public static void writeMap(java.lang.String filename,
                            java.util.Map map)
                     throws java.io.IOException,
                            java.lang.ClassNotFoundException
Writes the passed map to corresponding file

Parameters:
filename - The name of the file to which to write the passed map
map - The map to be stored
Throws:
java.io.IOException
java.lang.ClassNotFoundException

readMap

public static java.util.Map readMap(java.lang.String filename)
                             throws java.io.IOException,
                                    java.lang.ClassNotFoundException
Reads the map stored, in serialized object form, in the passed file and returns it. from the file where it is stored

Parameters:
filename - The file from where to read the Map
Returns:
The map that was read
Throws:
java.io.IOException
java.lang.ClassNotFoundException

listFiles

public static java.io.File[] listFiles(java.io.File f)
Same as the f.listFiles() in JDK1.3.


listFiles

public static java.io.File[] listFiles(java.io.File f,
                                       java.io.FilenameFilter filter)
Same as f.listFiles(FileNameFilter) in JDK1.2


getParentFile

public static java.io.File getParentFile(java.io.File f)
Same as f.getParentFile() in JDK1.3.


getCanonicalFile

public static java.io.File getCanonicalFile(java.io.File f)
                                     throws java.io.IOException
Same as f.getCanonicalFile() in JDK1.3.

Throws:
java.io.IOException

getFileExtension

public static java.lang.String getFileExtension(java.io.File f)
Utility method that returns the file extension of the given file.

Parameters:
f - the File instance that the extension should be extracted from
Returns:
the file extension string, or null if the extension could not be extracted

setWriteable

public static boolean setWriteable(java.io.File f)
Utility method to set a file as non read only. If the file is already writable, does nothing.

Parameters:
f - the File instance whose read only flag should be unset.