Interface IFileHandle
- All Known Implementing Classes:
FilesystemHandle,ResourceHandle
public interface IFileHandle
Generic handle to an
IFile or File instance.-
Field Summary
-
Method Summary
Modifier and Type Method Description voidclose()Close a file instance.booleancreateFile(boolean createHierarchy)Create a file.booleanexists()Check if a physical file exists.ObjectgetFile()Get the base file object.PathgetPath()Returns the java.io.File Path to the underlying fileStringread(int characters)Read characters from a file.StringreadLine()Read a line of data from a file.voidwrite(byte[] data)Write data to a file.voidwrite(String data)Write data to a file.
-
Field Details
-
READ
static final int READOpen file in read mode.- See Also:
- Constant Field Values
-
WRITE
static final int WRITEOpen file in write mode.- See Also:
- Constant Field Values
-
APPEND
static final int APPENDOpen file in append mode.- See Also:
- Constant Field Values
-
-
Method Details
-
read
Read characters from a file.- Parameters:
characters- amount of characters to read- Returns:
- data read from file
- Throws:
IOException- on access errors
-
readLine
Read a line of data from a file. Reads until a line feed is detected.- Returns:
- single line of text
- Throws:
IOException- on access errors
-
getPath
Returns the java.io.File Path to the underlying file- Returns:
- Path of the file
- Throws:
IOException- on access errors
-
write
Write data to a file. Uses platform default encoding to write strings to the file.- Parameters:
data- data to write- Throws:
IOException- on write errors
-
write
Write data to a file.- Parameters:
data- data to write- Throws:
IOException- on write errors
-
exists
boolean exists()Check if a physical file exists.- Returns:
truewhen file exists
-
createFile
Create a file.- Parameters:
createHierarchy- create parent folders if they do not exist- Returns:
trueon success- Throws:
Exception- on creation errors
-
close
void close()Close a file instance. -
getFile
Object getFile()Get the base file object. Returns anIFileor aFileinstance.- Returns:
- base file object
-