public class TextFile extends Object
| Constructor and Description |
|---|
TextFile(File file)
Instantiates a text file.
|
TextFile(String path)
Instantiates a text file.
|
TextFile(String dir,
String name)
Instantiates a text file.
|
| Modifier and Type | Method and Description |
|---|---|
TextFile |
append(String txt)
Adds text to the current content of this file.
|
TextFile |
appendLine(String txt)
Appends text to the current content of this file and adds a new line separator at the end.
|
void |
delete()
Deletes file and its content from the file system.
|
boolean |
equals(Object obj) |
File |
getFilePath()
Retrieves location of this text file.
|
String |
getPath()
Retrieves location of this text file.
|
int |
hashCode() |
String |
read()
Reads content of this file.
|
String |
readLine(long lnum)
Reads specified line from this file.
|
void |
save(String txt)
Saves text as the content of this text file
|
String |
toString() |
public TextFile(String path)
path - a path to the text file on the file system.public TextFile(String dir, String name)
dir - path to the directory, in which the file should be created.name - name of the file to create.public TextFile(File file)
file - a file, in which the text is stored.public String getPath()
public File getFilePath()
public void save(String txt) throws IOException
txt - a text to save in this file.IOException - when the text cannot be saved in this file.public TextFile append(String txt) throws IOException
txt - a text to add.IOException - when saving the added text fails.public TextFile appendLine(String txt) throws IOException
txt - a line of text to add to this file contentIOException - when saving the added line fails.public String read() throws IOException
IOException - if read failed.public String readLine(long lnum) throws IOException
lnum - number of the line to read. The line number starts from 1; there is no line 0 in a text file.null, if the line number does not exist in this file.IOException - when reading the specified line failspublic void delete()
throws IOException
IOException - if this file cannot be deleted.Copyright © 2017 SAP SE. All Rights Reserved.