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