Package com.hybris.datahub.core.io
Class TextFile
java.lang.Object
com.hybris.datahub.core.io.TextFile
A convenience class for reading text from a file.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds text to the current content of this file.appendLine(String txt) Appends text to the current content of this file and adds a new line separator at the end.voiddelete()Deletes file and its content from the file system.booleanRetrieves location of this text file.getPath()Retrieves location of this text file.inthashCode()read()Reads content of this file.readLine(long lnum) Reads specified line from this file.voidSaves text as the content of this text filetoString()
-
Constructor Details
-
TextFile
Instantiates a text file.- Parameters:
path- a path to the text file on the file system.
-
TextFile
Instantiates a text file.- Parameters:
dir- path to the directory, in which the file should be created.name- name of the file to create.
-
TextFile
Instantiates a text file.- Parameters:
file- a file, in which the text is stored.
-
-
Method Details
-
getPath
Retrieves location of this text file.- Returns:
- path to this text file on the file system.
-
getFilePath
Retrieves location of this text file.- Returns:
- path to this text file on the file system.
-
save
Saves text as the content of this text file- Parameters:
txt- a text to save in this file.- Throws:
IOException- when the text cannot be saved in this file.
-
append
Adds text to the current content of this file.- Parameters:
txt- a text to add.- Returns:
- this text file.
- Throws:
IOException- when saving the added text fails.
-
appendLine
Appends text to the current content of this file and adds a new line separator at the end.- Parameters:
txt- a line of text to add to this file content- Returns:
- this text file
- Throws:
IOException- when saving the added line fails.
-
read
Reads content of this file.- Returns:
- text saved in this file.
- Throws:
IOException- if read failed.
-
readLine
Reads specified line from this file.- Parameters:
lnum- number of the line to read. The line number starts from 1; there is no line 0 in a text file.- Returns:
- text on the specified line or
null, if the line number does not exist in this file. - Throws:
IOException- when reading the specified line fails
-
delete
Deletes file and its content from the file system.- Throws:
IOException- if this file cannot be deleted.
-
equals
-
hashCode
public int hashCode() -
toString
-