org.dllearner.utilities
Class Files

java.lang.Object
  extended by org.dllearner.utilities.Files

public class Files
extends Object

Author:
Jens Lehmann

Field Summary
static boolean debug
           
 
Constructor Summary
Files()
           
 
Method Summary
static void appendFile(File file, String content)
          Appends content to a file.
static void backupDirectory(String dir)
          copies all files in dir to "tmp/"+System.currentTimeMillis()
static void clearFile(File file)
           
static void createFile(File file, String content)
          Creates a new file with the given content or replaces the content of a file.
static void deleteDir(String dir)
          deletes all Files in the dir, does not delete the dir itself no warning is issued, use with care, cannot undelete files
static void deleteFile(File file)
           
static void deleteFile(String file)
           
static String[] listDir(String dir)
          lists all files in a directory
static void mkdir(String dir)
           
static String readFile(File file)
          Reads in a file.
static String readFile(URL file)
          Reads input from a URL and stores it in a string (only recommend for small files).
static String[] readFileAsArray(File file)
          Reads in a file as Array
static Object readObjectfromFile(File file)
           
static void writeObjectToFile(Object obj, File file)
          writes a serializable Object to a File.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

public static boolean debug
Constructor Detail

Files

public Files()
Method Detail

readFile

public static String readFile(URL file)
                       throws IOException
Reads input from a URL and stores it in a string (only recommend for small files).

Parameters:
file - URL of a file.
Returns:
Contents of the file.
Throws:
IOException - URL not accessible or content cannot be read for some reason.

readFile

public static String readFile(File file)
                       throws FileNotFoundException,
                              IOException
Reads in a file.

Parameters:
file - The file to read.
Returns:
Content of the file.
Throws:
FileNotFoundException
IOException

readFileAsArray

public static String[] readFileAsArray(File file)
                                throws FileNotFoundException,
                                       IOException
Reads in a file as Array

Parameters:
file - The file to read.
Returns:
StringArray with lines
Throws:
FileNotFoundException
IOException

writeObjectToFile

public static void writeObjectToFile(Object obj,
                                     File file)
writes a serializable Object to a File.

Parameters:
obj -
file -

readObjectfromFile

public static Object readObjectfromFile(File file)

createFile

public static void createFile(File file,
                              String content)
Creates a new file with the given content or replaces the content of a file.

Parameters:
file - The file to use.
content - Content of the file.

appendFile

public static void appendFile(File file,
                              String content)
Appends content to a file.

Parameters:
file - The file to create.
content - Content of the file.

clearFile

public static void clearFile(File file)

deleteFile

public static void deleteFile(String file)

deleteFile

public static void deleteFile(File file)

mkdir

public static void mkdir(String dir)

deleteDir

public static void deleteDir(String dir)
deletes all Files in the dir, does not delete the dir itself no warning is issued, use with care, cannot undelete files

Parameters:
dir - without a separator e.g. tmp/dirtodelete

listDir

public static String[] listDir(String dir)
lists all files in a directory

Parameters:
dir - without a separator e.g. tmp/dir
Returns:
a string array with filenames

backupDirectory

public static void backupDirectory(String dir)
copies all files in dir to "tmp/"+System.currentTimeMillis()

Parameters:
dir - the dir to be backupped


SourceForge.net Logo DL-Learner is licenced under the terms of the GNU General Public License.
Copyright © 2007-2011 Jens Lehmann