public class TextFile
extends java.lang.Object
| Constructor and Description |
|---|
TextFile(java.io.File file)
Instantiates a text file.
|
TextFile(java.lang.String path)
Instantiates a text file.
|
TextFile(java.lang.String dir,
java.lang.String name)
Instantiates a text file.
|
| Modifier and Type | Method and Description |
|---|---|
TextFile |
append(java.lang.String txt)
Adds text to the current content of this file.
|
TextFile |
appendLine(java.lang.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(java.lang.Object obj) |
java.io.File |
getFilePath()
Retrieves location of this text file.
|
java.lang.String |
getPath()
Retrieves location of this text file.
|
int |
hashCode() |
java.lang.String |
read()
Reads content of this file.
|
java.lang.String |
readLine(long lnum)
Reads specified line from this file.
|
void |
save(java.lang.String txt)
Saves text as the content of this text file
|
java.lang.String |
toString() |
public TextFile(java.lang.String path)
path - a path to the text file on the file system.public TextFile(java.lang.String dir,
java.lang.String name)
dir - path to the directory, in which the file should be created.name - name of the file to create.public TextFile(java.io.File file)
file - a file, in which the text is stored.public java.lang.String getPath()
public java.io.File getFilePath()
public void save(java.lang.String txt)
throws java.io.IOException
txt - a text to save in this file.java.io.IOException - when the text cannot be saved in this file.public TextFile append(java.lang.String txt) throws java.io.IOException
txt - a text to add.java.io.IOException - when saving the added text fails.public TextFile appendLine(java.lang.String txt) throws java.io.IOException
txt - a line of text to add to this file contentjava.io.IOException - when saving the added line fails.public java.lang.String read()
throws java.io.IOException
java.io.IOException - if read failed.public java.lang.String readLine(long lnum)
throws java.io.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.java.io.IOException - when reading the specified line failspublic void delete()
throws java.io.IOException
java.io.IOException - if this file cannot be deleted.public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2018 SAP SE. All Rights Reserved.