public class TextFile
extends java.io.File
Note this is just as memory-inefficient as handling a text file can be. Use with restraint.
Constructor and Description |
---|
TextFile(java.io.File filename)
Create a TextFile object to handle the named file with the platform
default encoding.
|
TextFile(java.io.File filename,
java.lang.String encoding)
Create a TextFile object to handle the named file with the given
encoding.
|
TextFile(java.lang.String filename)
Create a TextFile object to handle the named file with the platform
default encoding.
|
TextFile(java.lang.String filename,
java.lang.String encoding)
Create a TextFile object to handle the named file with the given
encoding.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
java.lang.String |
getEncoding() |
java.lang.String |
getText()
Read the whole file content and return it as a string.
|
int |
hashCode() |
void |
setEncoding(java.lang.String string) |
void |
setText(java.lang.String body)
Create the file with the given string as content -- or replace its
content with the given string if the file already existed.
|
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
public TextFile(java.io.File filename, java.lang.String encoding)
filename
- File to be read and written through this object.encoding
- Encoding to be used when reading and writing this file.public TextFile(java.io.File filename)
filename
- File to be read and written through this object.public TextFile(java.lang.String filename)
filename
- Name of the file to be read and written through this object.public TextFile(java.lang.String filename, java.lang.String encoding)
filename
- Name of the file to be read and written through this object.encoding
- Encoding to be used when reading and writing this file.public void setText(java.lang.String body)
body
- New content for the file.public java.lang.String getText()
public java.lang.String getEncoding()
public void setEncoding(java.lang.String string)
string
- Encoding to be used to read and write this file.public int hashCode()
hashCode
in class java.io.File
public boolean equals(java.lang.Object obj)
equals
in class java.io.File
Copyright © 1998-2019 Apache Software Foundation. All Rights Reserved.