Package org.apache.jorphan.io
Class TextFile
-
-
Field Summary
Fields Modifier and Type Field Description public Stringencodingpublic final Stringpathpublic final static charseparatorCharpublic final static Stringseparatorpublic final static charpathSeparatorCharpublic final static StringpathSeparator
-
Constructor Summary
Constructors Constructor Description TextFile(File filename, String encoding)Create a TextFile object to handle the named file with the given encoding. TextFile(File filename)Create a TextFile object to handle the named file with the platform default encoding. TextFile(String filename)Create a TextFile object to handle the named file with the platform default encoding. TextFile(String filename, String encoding)Create a TextFile object to handle the named file with the given encoding.
-
Method Summary
Modifier and Type Method Description StringgetEncoding()Returns encoding being used to read and write this file. voidsetEncoding(String string)Configures encoding to be used to read and write this file. voidsetText(String body)Create the file with the given string as content -- or replace its content with the given string if the file already existed. StringgetText()Read the whole file content and return it as a string. inthashCode()booleanequals(Object obj)-
Methods inherited from class java.io.File
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, delete, deleteOnExit, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setLastModified, setReadOnly, setReadable, setWritable, toPath, toString, toURI, toURL -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
TextFile
TextFile(File filename, String encoding)
Create a TextFile object to handle the named file with the given encoding.- Parameters:
filename- File to be read and written through this object.encoding- Encoding to be used when reading and writing this file.
-
TextFile
TextFile(File filename)
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
TextFile(String filename)
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.
-
-
Method Detail
-
getEncoding
String getEncoding()
Returns encoding being used to read and write this file.
- Returns:
Encoding being used to read and write this file.
-
setEncoding
void setEncoding(String string)
Configures encoding to be used to read and write this file.
- Parameters:
string- Encoding to be used to read and write this file.
-
setText
void setText(String body)
Create the file with the given string as content -- or replace its content with the given string if the file already existed.
- Parameters:
body- New content for the file.
-
getText
String getText()
Read the whole file content and return it as a string.
- Returns:
the content of the file
-
hashCode
int hashCode()
-
-
-
-