fileIO
Server-FileIO für JDito.
Methods
canRead
canRead(
pFile):boolean
Checks whether a file is readable.
Parameters
string | number | booleanFile for which you want to check whether it is readable or not.
Returns
boolean'true' if the file is readable. Otherwise 'false'.
Throws
May throw an exception.
Example
var readable = fileIO.canRead("c:\\temp\\orglist.txt");
canWrite
canWrite(
pFile):boolean
Checks whether a file can be overwritten.
Parameters
string | number | booleanThe file for which you want to check whether it can be overwritten or not.
Returns
boolean'true' if the file can be overwritten. Otherwise 'false'.
Throws
May throw an exception.
Example
var writable = fileIO.canWrite("c:\\temp\\orglist.txt");
copy
copy(
pSource,pTarget):void
Copies the given file to a specific target
Parameters
string | number | booleanPath to the file, that should be copied
string | number | booleanLocation where the file should be placed in
Returns
voidThrows
AditoException
exists
exists(
pFile):boolean
Checks whether a file exists.
Parameters
string | number | booleanThe file for which you want to check whether it exists or not.
Returns
boolean'true' if the file exists. Otherwise 'false'.
Throws
May throw an exception.
Example
var exists = fileIO.exists("c:\\temp\\orglist.txt");
getAbsolute
getAbsolute(
pFile):string
Returns the absolute name and path of a file.
Parameters
string | number | booleanThe file whose absolute path and name you want to retrieve.
Returns
stringThe absolute name and path of the file.
Throws
May throw an exception.
Example
var theAbsolute = fileIO.getAbsolute("orglist.txt");
// Output C:\temp\test.txt
getBulkData
getBulkData(
pFileName,pDataType,pCharset,pStartIndex,pRowCount):string
Retrieves blocks of data from a file.
Parameters
string | number | booleanThe name of the file.
numberThe type of the data.
string | number | booleanThe charset to be used for the file; null for the system default.
numberThe starting point of the block (for text: lines; for binary data: number of bytes).
numberSpecifies how large the block should be (for text: lines; for binary data: number of bytes).
Returns
stringThe data; bytes encoded as Base64.
Throws
May throw an exception.
Example
var fileName = "C:/temp/import.csv";
var startIndex = 0;
var rowCount = 100;
var data = fileIO.getBulkData(fileName, util.DATA_TEXT, "IBM850", startIndex, rowCount);
//Output of the first letter, column A/ line 1
question.showMessage(data[0]);
getData
getData(
pFileName,pDataType,pCharset?):string
Retrieves the data from a file.
Parameters
string | number | booleanThe name of the file.
numberThe expected type of the data. See swing.CLIENTCMD_*.
string | number | booleanThe character set of the data. 'null' for the system default.
Returns
stringThe data in bytes, Base64-encoded.
Throws
May throw an exception.
Example
var data = fileIO.getData("c:\\temp\\orglist.txt", util.DATA_TEXT, "UTF-8");
getLength
getLength(
pFile):number
Returns the size of the file.
Parameters
string | number | booleanThe element to be checked.
Returns
numberThe size of the file in bytes; 0 if it does not exist.
Throws
May throw an exception.
Example
var length = fileIO.getLength("c:\\temp\\orglist.txt");
getName
getName(
pFile):string
Returns the name of a file (without its path).
Parameters
string | number | booleanThe file whose name (without the path) you want to retrieve.
Returns
stringThe name of the file without a directory.
Throws
May throw an exception.
Example
var nameOnly = fileIO.getName("c:\\temp\\orglist.txt");
getParent
getParent(
pFile):string
Returns the parent directory of a file.
Parameters
string | number | booleanThe file for which you want to check the name of the parent directory.
Returns
stringThe name of the parent directory.
Throws
May throw an exception.
Example
var parent = fileIO.getParent("c:\\temp\\orglist.txt");
isDirectory
isDirectory(
pFile):boolean
Checks whether the element you passed is a directory.
Parameters
string | number | booleanThe element for which to check whether it is a directory or not.
Returns
boolean'true' if it is a directory. Otherwise 'false'.
Throws
May throw an exception.
Example
var directory = fileIO.isDirectory("c:\\temp");
isFile
isFile(
pFile):boolean
Checks whether the element you passed is a file.
Parameters
string | number | booleanThe element for which to check whether it is a file or not.
Returns
boolean'true' if it is a file. Otherwise 'false'.
Throws
May throw an exception.
Example
var file = fileIO.isFile("c:\\temp\\orglist.txt");
isHidden
isHidden(
pFile):boolean
Checks whether the element you passed is hidden.
Parameters
string | number | booleanThe element for which to check whether it is hidden or not.
Returns
boolean'true' if the file is hidden. Otherwise 'false'.
Throws
May throw an exception.
Example
var hidden = fileIO.isHidden("c:\\temp\\orglist.txt");
lastModified
lastModified(
pFile):number
Returns the time when the file was last modified.
Parameters
string | number | booleanThe element to be checked.
Returns
numberThe time in ms since January 1, 1970; 0 if the file does not exist or is not readable.
Throws
May throw an exception.
Example
var lastModified = fileIO.lastModified("c:\\temp\\orglist.txt");
listFiles
listFiles(
pFile,pFilter?):string[]
Lists the contents of the directory you passed.
Parameters
string | number | booleanThe name of the directory.
string | number | booleanA search filter, such as "*.JPG".
Returns
string[]The list of files and directories within the specified directory.
Throws
May throw an exception.
Example
var filelist = fileIO.listFiles("c:\\temp", "*.JPG");
mkdir
mkdir(
pFile,pCreateNonExistant):boolean
Creates a directory with the specified name.
Parameters
string | number | booleanThe name of the directory.
booleanIf 'true', the system will also create any parent directories that do not exist yet.
Returns
boolean'true' if the directory could be created successfully.
Throws
May throw an exception.
Example
var directory = fileIO.mkdir("c:\\temp\\sumtemp", true);
move
move(
pSource,pTarget):void
Moves the given file to a specific target
Parameters
string | number | booleanPath to the file, that should be moved
string | number | booleanLocation where the file should be placed in
Returns
voidThrows
AditoException
remove
remove(
pFile):boolean
Deletes a file.
Parameters
string | number | booleanThe file to be deleted.
Returns
boolean'true' if the file was deleted. Otherwise 'false'.
Throws
May throw an exception.
Example
var removable = fileIO.remove("c:\\temp\\orglist.txt");
removeOnExit
removeOnExit(
pFile):void
Flags a file to be deleted when exiting the VM.
Parameters
string | number | booleanThe name of the file.
Returns
voidThrows
May throw an exception.
Example
fileIO.removeOnExit("c:\\temp\\orglist_old.txt");
rename
rename(
pFile,pNewFile):boolean
Renames the file. Whether the file can also be renamed cross-system is dependent on the operating system.
Parameters
string | number | booleanThe name of the file.
string | number | booleanThe new file name.
Returns
boolean'true' if the action was successful.
Throws
May throw an exception.
Example
var rename = fileIO.rename("c:\\temp\\orglist.txt", "c:\\temp\\orglist_old.txt");
setReadOnly
setReadOnly(
pFile):boolean
Enables write protection for a file.
Parameters
string | number | booleanThe name of the file.
Returns
boolean'true' if the action was successful.
Throws
May throw an exception.
Example
var readonly = fileIO.setReadOnly("c:\\temp\\orglist.txt");
storeData
storeData(
pFileName,pData,pDataType,pAppend,pCharset?):void
Saves data to a file on the server. If you want to save the file on the client, use the swing.doClient* methods with swing.CLIENTCMD_STOREDATA.
Parameters
string | number | booleanThe filename of the file to which the data is to be saved.
anyThe data to be saved.
numberThe data type, util.DATA_TEXT or util.DATA_BINARY.
boolean'true' if the contents is to be appended to an existing file; otherwise 'false'.
string | number | booleanCharacter set of the file as "UTF-8", "UTF-16", "ISO-8859-15", etc. You can specify any valid Java charset. 'Null' to use the systems default charset.
Returns
voidThrows
May throw an exception.
Example
fileIO.storeData("c:/orglist.txt", "This are the organisations to save!", util.DATA_TEXT, false, "UTF-16");