javatools.util
Class FileUtils

java.lang.Object
  extended by javatools.util.FileUtils

public class FileUtils
extends java.lang.Object

This class is part of the Java Tools (see http://mpii.de/yago-naga/javatools). It is licensed under the Creative Commons Attribution License (see http://creativecommons.org/licenses/by/3.0) by the YAGO-NAGA team (see http://mpii.de/yago-naga) Some utility methods for arrays


Constructor Summary
FileUtils()
           
 
Method Summary
static java.util.Collection<java.io.File> getAllFiles(java.io.File directory)
          Collects all non-directory files in the given input directory (recursively).
static java.io.BufferedReader getBufferedUTF8Reader(java.io.File file)
          Creates a BufferedReader for UTF-8-encoded files
static java.io.BufferedReader getBufferedUTF8Reader(java.io.InputStream inputStream)
          Creates a BufferedReader the UTF-8-encoded InputStream
static java.io.BufferedReader getBufferedUTF8Reader(java.lang.String fileName)
          Creates a BufferedReader for UTF-8-encoded files
static java.io.BufferedWriter getBufferedUTF8Writer(java.io.File file)
          Creates a BufferedWriter for UTF-8-encoded files
static java.io.BufferedWriter getBufferedUTF8Writer(java.lang.String fileName)
          Creates a BufferedWriter for UTF-8-encoded files
static java.lang.String getFileContent(java.io.File file)
          Returns the content of the (UTF-8 encoded) file as string.
static void main(java.lang.String[] args)
           
static boolean verifyOrderedFile(java.io.File check, boolean descending)
          Verifies that a file is lexicographically order (ascending or descending)
static void writeFileContent(java.io.File file, java.lang.String content)
          Writes the content of the string to the (UTF-8 encoded) file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtils

public FileUtils()
Method Detail

getBufferedUTF8Reader

public static java.io.BufferedReader getBufferedUTF8Reader(java.io.File file)
                                                    throws java.io.FileNotFoundException
Creates a BufferedReader for UTF-8-encoded files

Parameters:
file - File in UTF-8 encoding
Returns:
BufferedReader for file
Throws:
java.io.FileNotFoundException

getBufferedUTF8Reader

public static java.io.BufferedReader getBufferedUTF8Reader(java.lang.String fileName)
                                                    throws java.io.FileNotFoundException
Creates a BufferedReader for UTF-8-encoded files

Parameters:
fileName - Path to file in UTF-8 encoding
Returns:
BufferedReader for file
Throws:
java.io.FileNotFoundException

getBufferedUTF8Reader

public static java.io.BufferedReader getBufferedUTF8Reader(java.io.InputStream inputStream)
Creates a BufferedReader the UTF-8-encoded InputStream

Parameters:
inputStream - InputStream in UTF-8 encoding
Returns:
BufferedReader for inputStream

getBufferedUTF8Writer

public static java.io.BufferedWriter getBufferedUTF8Writer(java.io.File file)
                                                    throws java.io.FileNotFoundException
Creates a BufferedWriter for UTF-8-encoded files

Parameters:
file - File in UTF-8 encoding
Returns:
BufferedWriter for file
Throws:
java.io.FileNotFoundException

getBufferedUTF8Writer

public static java.io.BufferedWriter getBufferedUTF8Writer(java.lang.String fileName)
                                                    throws java.io.FileNotFoundException
Creates a BufferedWriter for UTF-8-encoded files

Parameters:
fileName - Path to file in UTF-8 encoding
Returns:
BufferedWriter for file
Throws:
java.io.FileNotFoundException

getFileContent

public static java.lang.String getFileContent(java.io.File file)
                                       throws java.io.IOException
Returns the content of the (UTF-8 encoded) file as string. Linebreaks are encoded as unix newlines (\n)

Parameters:
file - File to get String content from
Returns:
String content of file.
Throws:
java.io.IOException

writeFileContent

public static void writeFileContent(java.io.File file,
                                    java.lang.String content)
                             throws java.io.IOException
Writes the content of the string to the (UTF-8 encoded) file.

Parameters:
file - File to write String content to.
Throws:
java.io.IOException

verifyOrderedFile

public static boolean verifyOrderedFile(java.io.File check,
                                        boolean descending)
                                 throws java.io.IOException
Verifies that a file is lexicographically order (ascending or descending)

Parameters:
check - File to check
descending - true if ordering should be descending, false if it should be ascending
Returns:
true if file is order, false otherwise
Throws:
java.io.IOException

getAllFiles

public static java.util.Collection<java.io.File> getAllFiles(java.io.File directory)
Collects all non-directory files in the given input directory (recursively).

Parameters:
directory - Input directory.
Returns:
All non-directory files, recursively.

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Throws:
java.io.IOException