Skip to main content
Version: 2026.0

fileIO

Server-FileIO für JDito.

Methods​

canRead​

canRead(pFile): boolean

Checks whether a file is readable.

Parameters​

pFile
string | number | boolean

File 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​

pFile
string | number | boolean

The 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​

pSource
string | number | boolean

Path to the file, that should be copied

pTarget
string | number | boolean

Location where the file should be placed in

Returns​

void

Throws​

AditoException


exists​

exists(pFile): boolean

Checks whether a file exists.

Parameters​

pFile
string | number | boolean

The 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​

pFile
string | number | boolean

The file whose absolute path and name you want to retrieve.

Returns​

string

The 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​

pFileName
string | number | boolean

The name of the file.

pDataType
number

The type of the data.

pCharset
string | number | boolean

The charset to be used for the file; null for the system default.

pStartIndex
number

The starting point of the block (for text: lines; for binary data: number of bytes).

pRowCount
number

Specifies how large the block should be (for text: lines; for binary data: number of bytes).

Returns​

string

The 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​

pFileName
string | number | boolean

The name of the file.

pDataType
number

The expected type of the data. See swing.CLIENTCMD_*.

pCharset?
string | number | boolean

The character set of the data. 'null' for the system default.

Returns​

string

The 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​

pFile
string | number | boolean

The element to be checked.

Returns​

number

The 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​

pFile
string | number | boolean

The file whose name (without the path) you want to retrieve.

Returns​

string

The 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​

pFile
string | number | boolean

The file for which you want to check the name of the parent directory.

Returns​

string

The 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​

pFile
string | number | boolean

The 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​

pFile
string | number | boolean

The 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​

pFile
string | number | boolean

The 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​

pFile
string | number | boolean

The element to be checked.

Returns​

number

The 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​

pFile
string | number | boolean

The name of the directory.

pFilter?
string | number | boolean

A 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​

pFile
string | number | boolean

The name of the directory.

pCreateNonExistant
boolean

If '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​

pSource
string | number | boolean

Path to the file, that should be moved

pTarget
string | number | boolean

Location where the file should be placed in

Returns​

void

Throws​

AditoException


remove​

remove(pFile): boolean

Deletes a file.

Parameters​

pFile
string | number | boolean

The 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​

pFile
string | number | boolean

The name of the file.

Returns​

void

Throws​

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​

pFile
string | number | boolean

The name of the file.

pNewFile
string | number | boolean

The 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​

pFile
string | number | boolean

The 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​

pFileName
string | number | boolean

The filename of the file to which the data is to be saved.

pData
any

The data to be saved.

pDataType
number

The data type, util.DATA_TEXT or util.DATA_BINARY.

pAppend
boolean

'true' if the contents is to be appended to an existing file; otherwise 'false'.

pCharset?
string | number | boolean

Character 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​

void

Throws​

May throw an exception.

Example​

fileIO.storeData("c:/orglist.txt", "This are the organisations to save!", util.DATA_TEXT, false, "UTF-16");