Class TextFile
java.lang.Object
java.io.File
org.apache.jorphan.io.TextFile
- All Implemented Interfaces:
Serializable, Comparable<File>
Utility class to handle text files as a single lump of text.
Note this is just as memory-inefficient as handling a text file can be. Use with restraint.
- Version:
- $Revision: 1639469 $
- See Also:
-
Field Summary
Fields inherited from class File
pathSeparator, pathSeparatorChar, separator, separatorChar -
Constructor Summary
ConstructorsConstructorDescriptionCreate a TextFile object to handle the named file with the platform default encoding.Create a TextFile object to handle the named file with the given encoding.Create a TextFile object to handle the named file with the platform default encoding.Create a TextFile object to handle the named file with the given encoding. -
Method Summary
Modifier and TypeMethodDescriptionbooleangetText()Read the whole file content and return it as a string.inthashCode()voidsetEncoding(String string) voidCreate the file with the given string as content -- or replace it's content with the given string if the file already existed.Methods inherited from class File
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toPath, toString, toURI, toURL
-
Constructor Details
-
TextFile
-
TextFile
Create a TextFile object to handle the named file with the platform default encoding.- Parameters:
filename- File to be read and written through this object.
-
TextFile
Create a TextFile object to handle the named file with the platform default encoding.- Parameters:
filename- Name of the file to be read and written through this object.
-
TextFile
-
-
Method Details
-
setText
Create the file with the given string as content -- or replace it's content with the given string if the file already existed.- Parameters:
body- New content for the file.
-
getText
Read the whole file content and return it as a string.- Returns:
- the content of the file
-
getEncoding
- Returns:
- Encoding being used to read and write this file.
-
setEncoding
- Parameters:
string- Encoding to be used to read and write this file.
-
hashCode
-
equals
-