|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmoj.util.FileTools
public class FileTools
A small utility class that contains methods for handling files.
Constructor Summary | |
---|---|
FileTools()
|
Method Summary | |
---|---|
static java.lang.String |
readFile2String(java.lang.String filename)
Reads a file into a String using cpdetector for code page detection. |
static java.lang.String |
readFile2String(java.lang.String filename,
java.nio.charset.Charset cs)
Reads a file into a String using the provided charset. |
static java.lang.String |
readFile2StringVanilla(java.lang.String filename)
Reads a file into a String without specifying charset. |
static java.util.HashSet<java.lang.String> |
readVocabulary(java.lang.String vocabularyfile)
Reads a list of words from a file into a HashSet . |
static java.util.HashSet<java.lang.String> |
readVocabulary(java.lang.String vocabularyfile,
boolean lowercase)
Reads a list of words from a file into a HashSet . |
static void |
traverseDirectory(java.lang.String dirItem,
TraverseDirectoryHelper helper)
Recursively traverses a directory structure and executes the supplied helper for each file it encounters. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileTools()
Method Detail |
---|
public static java.lang.String readFile2String(java.lang.String filename)
String
using cpdetector for code page detection.
filename
- name of the file to read into a String
String
containing the given file (line breaks preserved)public static java.lang.String readFile2String(java.lang.String filename, java.nio.charset.Charset cs)
String
using the provided charset.
filename
- name of the file to read into a String
cs
- the Charset
to use when reading the file
String
containing the given file (line breaks preserved)public static java.lang.String readFile2StringVanilla(java.lang.String filename)
String
without specifying charset.
filename
- name of the file to read into a String
String
containing the given file (line breaks preserved)public static void traverseDirectory(java.lang.String dirItem, TraverseDirectoryHelper helper)
dirItem
- directory to traverse or file to processhelper
- an assisting class that processes a file passed to itpublic static java.util.HashSet<java.lang.String> readVocabulary(java.lang.String vocabularyfile)
HashSet
.
All incoming words are transformed to lower case.
vocabularyfile
- filename of the file containing the list of words
HashSet
containing the wordspublic static java.util.HashSet<java.lang.String> readVocabulary(java.lang.String vocabularyfile, boolean lowercase)
HashSet
.
All incoming words are optionally transformed to lower case.
vocabularyfile
- filename of the file containing the list of wordslowercase
- true
if all words should be converted to
lower case, false
original casing should be preserved
HashSet
containing the words
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |