public class FileMgmt
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.util.Scanner |
fileData
The content of the file.
|
Constructor and Description |
---|
FileMgmt() |
Modifier and Type | Method and Description |
---|---|
void |
closeFile(java.lang.String fileName)
Close a specified file
|
java.util.Scanner |
getData()
This class is used to get the content of the file
|
void |
openFile(java.lang.String fileName)
Open a specified file
|
java.lang.String |
readFile(java.lang.String fileName)
Read a file, and Return the content of that file in String
|
java.lang.String |
readLine(java.lang.String fileName,
int lineIndex)
Returns the content of a line in file at the specified index.
|
void |
writeFile(java.lang.String fileName,
java.lang.String fileContent,
boolean appendOrNot)
Write specified data to a specified file in terms of appending
data to the end of the file or not.
|
protected java.util.Scanner fileData
Scanner
public java.util.Scanner getData()
public void openFile(java.lang.String fileName)
fileName
- the file to be openpublic void closeFile(java.lang.String fileName)
fileName
- the file to be closedpublic java.lang.String readFile(java.lang.String fileName)
fileName
- the file name of a txt file that store datapublic java.lang.String readLine(java.lang.String fileName, int lineIndex)
fileName
- the name of a file read fromlineIndex
- the index of the desired linepublic void writeFile(java.lang.String fileName, java.lang.String fileContent, boolean appendOrNot)
fileName
- name of the file to be writtenfileContent
- the content to be writtenappendOrNot
- append to the original file data or notFileWriter