Class Files
java.lang.Object
io.github.javaezlib.javaez.extensions.Files
The Files extension for handling I/O with files.
- Since:
- 1.0
- Author:
- Red050911
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidCloses any open files.static voidMakes a filestatic voidmakeFolder(String path) Makes a folderstatic voidopenFileForReading(String path) Opens a file in READ mode.static voidopenFileForWriting(String path, boolean append) Opens a file in WRITE mode.static StringreadLine()Reads a line of a READ-MODE file.static voidTrashes a file or folder.static voidWrites a line to a WRITE-MODE file.
-
Constructor Details
-
Files
public Files()
-
-
Method Details
-
openFileForReading
Opens a file in READ mode. Without calling this,readLine()will not work.- Parameters:
path- The path of the file to read.- Since:
- 1.0
-
openFileForWriting
Opens a file in WRITE mode. Without calling this,writeLine(String)will not work.- Parameters:
path- Path of the file to write.append- If we should append to the file. If true, new lines will be added. If false, the file will be replaced.- Since:
- 1.0
-
closeFile
public static void closeFile()Closes any open files. You must run this after you are finished reading/writing to a file.- Since:
- 1.0
-
readLine
Reads a line of a READ-MODE file. You must open a file this way usingopenFileForReading(String)or this will not work.- Returns:
- The line read from the file, null if EOF
- Since:
- 1.0
-
writeLine
Writes a line to a WRITE-MODE file. You must open a file this way usingopenFileForWriting(String, boolean)or this will not work.- Parameters:
line- What to write to the file.- Since:
- 1.0
-
makeFile
Makes a file- Parameters:
path- Where to create this file- Since:
- 1.4
-
makeFolder
Makes a folder- Parameters:
path- Where to create this file- Since:
- 1.4
-
trashFile
Trashes a file or folder.- Parameters:
path- Path of the file to trash- Since:
- 1.4
-