Class FileHandlingFunctions
java.lang.Object
com.scriptbasic.utility.functions.file.FileHandlingFunctions
This class implements static methods, which can be used from BASIC programs
to access the file system.
Note that these functions are NOT registered into the BASIC interpreter by default. The embedding application has to ask the interpreter to register the methods of this class if it wants BASIC programs access the file system.
- Author:
- Peter Verhas
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringabsoluteFileName(String fileName) static voidclose(FileHandler fh) static voiddeleteFile(String fileName) static booleanfileCanExecute(String fileName) static booleanfileExists(String fileName) static booleanfileIsExecutable(String fileName) static booleanfileIsReadable(String fileName) static booleanfileIsWritable(String fileName) static LongfileLength(String fileName) static Longstatic booleanisDirectory(String fileName) static booleanstatic booleanstatic LonglastModified(String fileName) static BasicArraystatic booleanstatic FileHandlerOpens a file and returns a file handler.static StringparentDirectory(String fileName) static voidprintf(FileHandler fh, String line) static voidprintfln(FileHandler fh, String line) static byte[]read(FileHandler fh, int len) static StringreadLine(FileHandler fh) static booleanrenameFile(String fileNameFrom, String fileNameTo) static booleansetExecutable(String fileName, boolean executable, boolean ownerOnly) static booleansetLastModified(String fileName, Long time) static booleansetReadable(String fileName, boolean readable, boolean ownerOnly) static booleansetRedOnly(String fileName) static booleansetWritable(String fileName, boolean writable, boolean ownerOnly) static voidwrite(FileHandler fh, byte[] buffer)
-
Method Details
-
open
Opens a file and returns a file handler. Files can be opened read, write or append. Also the mode can be binary or text. Default is read and text.- Parameters:
fileName- the name of the file to be opened.mode- the mode how to open the file- Returns:
- return value
-
readLine
- Throws:
BasicRuntimeExceptionIOException
-
read
- Throws:
BasicRuntimeExceptionIOException
-
printf
- Throws:
BasicRuntimeExceptionIOException
-
printfln
- Throws:
IOExceptionBasicRuntimeException
-
write
- Throws:
BasicRuntimeExceptionIOException
-
close
- Throws:
Exception
-
deleteFile
-
fileExists
-
fileCanExecute
-
fileIsReadable
-
fileIsWritable
-
fileIsExecutable
-
isDirectory
-
isFile
-
absoluteFileName
-
freeSpace
-
parentDirectory
-
isHidden
-
mkdir
-
renameFile
-
setExecutable
-
setReadable
-
setWritable
-
setRedOnly
-
lastModified
-
fileLength
-
setLastModified
-
listFiles
- Throws:
ScriptBasicException
-