Child pages
  • JSFile

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Divcache
Div
iddescription
HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Summary
Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)canRead()
styleindexdisplay:none

DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY (EXCEPT INSIDE THE DIV BELOW WITH ID=DESCRIPTION), UNLESS YOU KNOW WHAT YOU'RE DOING.
THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO AUTO UPDATE THE CONTENT THROUGH THE DOC GENERATOR.

true
refresh100d
showRefreshtrue
iddoc
titleRefresh page
showDatetrue
retryEnable
id

servoy sReturnTypes2100%height: 30px;2Supported ClientssWordListSmartClientsWordListWebClientsWordListNGClient

servoy sSummary12%30%58%height: 30px;3Methods SummaryReturns true if the file exists and is readable (has access to it) - works on remote files too. Table Row (tr)

Table Cell (td)
Boolean
Table Cell (td)canWrite()
Returns true if the file exists and can be modified - works on remote files too. Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)createNewFile()
Creates the file on disk if needed. Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)deleteFile()
Deletes the file from the Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)exists()
Deletes the file from the disk if possible.Returns true if the file/directory exists on the filesystem - works on remote files too. Table Row (tr)
Table Cell (td)
JSFile
Table Cell (td)getAbsoluteFile()
Table Row (tr)
Table Cell (td)
String
Table Cell (td)getAbsolutePath()
Returns a JSFile instance that corresponds to the absolute form of this pathname - works on remote files too.Returns a String representation of the absolute form of this pathname - works on remote files too. Table Row (tr)
Table Cell (td)
byte[]
Table Cell (td)getBytes()
Table Row (tr)
Table Cell (td)
String
Table Cell (td)getContentType()
Gets the contents (bytes) for the file data.Returns the contenttype of this file, like for example 'application/pdf' - works on remote files too. Table Row (tr)
Table Cell (td)
String
Table Cell (td)getName()
Returns the Table Row (tr)
Table Cell (td)
String
Table Cell (td)getParent()
Returns the name of the file.Returns the String representation of the path of the parent of this file - works on remote files too. Table Row (tr)
Table Cell (td)
JSFile
Table Cell (td)getParentFile()
Table Row (tr)
Table Cell (td)
String
Table Cell (td)getPath()
Returns a JSFile instance that corresponds to the parent of this file - works on remote files too.Returns a String holding the path to the file - works on remote files too. Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)isAbsolute()
Table Cell (td)
Boolean
Table Cell (td)isDirectory()
Returns true if the path is absolute. Table Row (tr)Returns true if the file is a directory - works on remote files too. Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)isFile()
Returns true if
Table Cell (td)
Boolean
Table Cell (td)isHidden()
Returns true if the file is a file and not a regular file - works on remote files too. Table Row (tr)Returns true if the file is hidden (a file system attribute) - works on remote files too. Table Row (tr)
Table Cell (td)
Date
Table Cell (td)lastModified()
Returns the time/date of the last modification on the file - works on remote files too. Table Row (tr)
Table Cell (td)
String[]
Table Cell (td)list()
Table Cell (td)listFiles()
Returns an array of strings naming the files and directories located inside the file, if the file is a directory - works on remote files too. Table Row (tr)
Table Cell (td)
JSFile[]
Returns an array of JSFiles naming the files and directories located inside the file, if the file is a directory - works on remote files too. Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)mkdir()
Creates a directory on disk if possible. Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)mkdirs()
Creates renameTo(destination)
Creates a directory on disk, together with all its parent directories, if possible. Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)Renames the file to a different name. Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)setBytes(bytes)
Set the content of the file (local or remote) to the bytes provided<br/>
Will not create a new file if one doesn't exist Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)setBytes(bytes, createFile)
Table Cell (td)setLastModified(date)
Set the content of the file (local or remote) to the bytes provided Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)setReadOnly()
Sets the readonly attribute of the Sets the date/time of the last modification on the file. Table Row (tr)
Table Cell (td)
Boolean
Table Cell (td)size()
Sets the readonly attribute of the file/directory. Table Row (tr)
Table Cell (td)
Number
Returns the size in bytes of the file.

HTML Table

functionclass Colgroup Tag Colcolspanservoy sDetail2width100%

Col
Table Head (thead) Table Row (tr)styleheight:30px;
Table Head (th)
colspan2
Method Details
Table Body (tbody)
idcanRead
Table Row (tr)
idname
Table Cell (td)

canRead

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
canRead
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns true if the file exists and is readable (has access to it) - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('./big.jpg');
// or for a remote file:
// var f = plugins.convertToRemoteJSFile('/images/big.jpg');
if (f && f.exists()) {
	application.output('is absolute: ' + f.isAbsolute());
	application.output('is dir: ' + f.isDirectory());
	application.output('is file: ' + f.isFile());
	application.output('is hidden: ' + f.isHidden());
	application.output('can read: ' + f.canRead());
	application.output('can write: ' + f.canWrite());
	application.output('last modified: ' + f.lastModified());
	application.output('name: ' + f.getName());
	application.output('path: ' + f.getPath());
	application.output('absolute path: ' + f.getAbsolutePath());
	application.output('content type: ' + f.getContentType());
	application.output('size: ' + f.size());
}
else {
	application.output('File/folder not found.');
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idcanWrite
Table Row (tr)
idname
Table Cell (td)

canWrite

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
canWrite
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns true if the file exists and can be modified - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('./big.jpg');
// or for a remote file:
// var f = plugins.convertToRemoteJSFile('/images/big.jpg');
if (f && f.exists()) {
	application.output('is absolute: ' + f.isAbsolute());
	application.output('is dir: ' + f.isDirectory());
	application.output('is file: ' + f.isFile());
	application.output('is hidden: ' + f.isHidden());
	application.output('can read: ' + f.canRead());
	application.output('can write: ' + f.canWrite());
	application.output('last modified: ' + f.lastModified());
	application.output('name: ' + f.getName());
	application.output('path: ' + f.getPath());
	application.output('absolute path: ' + f.getAbsolutePath());
	application.output('content type: ' + f.getContentType());
	application.output('size: ' + f.size());
}
else {
	application.output('File/folder not found.');
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idcreateNewFile
Table Row (tr)
idname
Table Cell (td)

createNewFile

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
createNewFile
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Creates the file on disk if needed. Returns true if the file (name) did not already exists and had to be created - for remote, use the streamFilesToServer to stream a file.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('story.txt');
if (!f.exists())
	f.createNewFile();
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
iddeleteFile
Table Row (tr)
idname
Table Cell (td)

deleteFile

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
deleteFile
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Deletes the file from the disk if possible. Returns true if the file could be deleted. If the file is a directory, then it must be empty in order to be deleted - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('story.txt');
// or for a remote file:
// var f = plugins.convertToRemoteJSFile('/story.txt');
if (f && f.exists())
	f.deleteFile();
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idexists
Table Row (tr)
idname
Table Cell (td)

exists

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
exists
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns true if the file/directory exists on the filesystem - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('./big.jpg');
// or for a remote file:
// var f = plugins.convertToRemoteJSFile('/images/big.jpg');
if (f && f.exists()) {
	application.output('is absolute: ' + f.isAbsolute());
	application.output('is dir: ' + f.isDirectory());
	application.output('is file: ' + f.isFile());
	application.output('is hidden: ' + f.isHidden());
	application.output('can read: ' + f.canRead());
	application.output('can write: ' + f.canWrite());
	application.output('last modified: ' + f.lastModified());
	application.output('name: ' + f.getName());
	application.output('path: ' + f.getPath());
	application.output('absolute path: ' + f.getAbsolutePath());
	application.output('content type: ' + f.getContentType());
	application.output('size: ' + f.size());
}
else {
	application.output('File/folder not found.');
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetAbsoluteFile
Table Row (tr)
idname
Table Cell (td)

getAbsoluteFile

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
JSFile
Span
stylefont-weight: bold;
getAbsoluteFile
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns a JSFile instance that corresponds to the absolute form of this pathname - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
JSFile
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('story.txt');
// or for a remote file:
// var f = plugins.file.convertToRemoteJSFile('/story.txt');
application.output('parent folder: ' + f.getAbsoluteFile().getParent());
application.output('parent folder has ' + f.getAbsoluteFile().getParentFile().listFiles().length + ' entries');
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetAbsolutePath
Table Row (tr)
idname
Table Cell (td)

getAbsolutePath

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
String
Span
stylefont-weight: bold;
getAbsolutePath
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns a String representation of the absolute form of this pathname - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('./big.jpg');
// or for a remote file:
// var f = plugins.convertToRemoteJSFile('/images/big.jpg');
if (f && f.exists()) {
	application.output('is absolute: ' + f.isAbsolute());
	application.output('is dir: ' + f.isDirectory());
	application.output('is file: ' + f.isFile());
	application.output('is hidden: ' + f.isHidden());
	application.output('can read: ' + f.canRead());
	application.output('can write: ' + f.canWrite());
	application.output('last modified: ' + f.lastModified());
	application.output('name: ' + f.getName());
	application.output('path: ' + f.getPath());
	application.output('absolute path: ' + f.getAbsolutePath());
	application.output('content type: ' + f.getContentType());
	application.output('size: ' + f.size());
}
else {
	application.output('File/folder not found.');
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetBytes
Table Row (tr)
idname
Table Cell (td)

getBytes

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
byte[]
Span
stylefont-weight: bold;
getBytes
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Gets the contents (bytes) for the file data.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
byte[]
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var theFile = plugins.file.showFileOpenDialog();
application.output('The file size in bytes: ' + theFile.getBytes());
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetContentType
Table Row (tr)
idname
Table Cell (td)

getContentType

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
String
Span
stylefont-weight: bold;
getContentType
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns the contenttype of this file, like for example 'application/pdf' - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('./big.jpg');
// or for a remote file:
// var f = plugins.convertToRemoteJSFile('/images/big.jpg');
if (f && f.exists()) {
	application.output('is absolute: ' + f.isAbsolute());
	application.output('is dir: ' + f.isDirectory());
	application.output('is file: ' + f.isFile());
	application.output('is hidden: ' + f.isHidden());
	application.output('can read: ' + f.canRead());
	application.output('can write: ' + f.canWrite());
	application.output('last modified: ' + f.lastModified());
	application.output('name: ' + f.getName());
	application.output('path: ' + f.getPath());
	application.output('absolute path: ' + f.getAbsolutePath());
	application.output('content type: ' + f.getContentType());
	application.output('size: ' + f.size());
}
else {
	application.output('File/folder not found.');
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetName
Table Row (tr)
idname
Table Cell (td)

getName

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
String
Span
stylefont-weight: bold;
getName
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns the name of the file. The name consists in the last part of the file path - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('./big.jpg');
// or for a remote file:
// var f = plugins.convertToRemoteJSFile('/images/big.jpg');
if (f && f.exists()) {
	application.output('is absolute: ' + f.isAbsolute());
	application.output('is dir: ' + f.isDirectory());
	application.output('is file: ' + f.isFile());
	application.output('is hidden: ' + f.isHidden());
	application.output('can read: ' + f.canRead());
	application.output('can write: ' + f.canWrite());
	application.output('last modified: ' + f.lastModified());
	application.output('name: ' + f.getName());
	application.output('path: ' + f.getPath());
	application.output('absolute path: ' + f.getAbsolutePath());
	application.output('content type: ' + f.getContentType());
	application.output('size: ' + f.size());
}
else {
	application.output('File/folder not found.');
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetParent
Table Row (tr)
idname
Table Cell (td)

getParent

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
String
Span
stylefont-weight: bold;
getParent
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns the String representation of the path of the parent of this file - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('story.txt');
// or for a remote file:
// var f = plugins.file.convertToRemoteJSFile('/story.txt');
application.output('parent folder: ' + f.getAbsoluteFile().getParent());
application.output('parent folder has ' + f.getAbsoluteFile().getParentFile().listFiles().length + ' entries');
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetParentFile
Table Row (tr)
idname
Table Cell (td)

getParentFile

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
JSFile
Span
stylefont-weight: bold;
getParentFile
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns a JSFile instance that corresponds to the parent of this file - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
JSFile
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('story.txt');
// or for a remote file:
// var f = plugins.file.convertToRemoteJSFile('/story.txt');
application.output('parent folder: ' + f.getAbsoluteFile().getParent());
application.output('parent folder has ' + f.getAbsoluteFile().getParentFile().listFiles().length + ' entries');
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idgetPath
Table Row (tr)
idname
Table Cell (td)

getPath

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
String
Span
stylefont-weight: bold;
getPath
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns a String holding the path to the file - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('./big.jpg');
// or for a remote file:
// var f = plugins.convertToRemoteJSFile('/images/big.jpg');
if (f && f.exists()) {
	application.output('is absolute: ' + f.isAbsolute());
	application.output('is dir: ' + f.isDirectory());
	application.output('is file: ' + f.isFile());
	application.output('is hidden: ' + f.isHidden());
	application.output('can read: ' + f.canRead());
	application.output('can write: ' + f.canWrite());
	application.output('last modified: ' + f.lastModified());
	application.output('name: ' + f.getName());
	application.output('path: ' + f.getPath());
	application.output('absolute path: ' + f.getAbsolutePath());
	application.output('content type: ' + f.getContentType());
	application.output('size: ' + f.size());
}
else {
	application.output('File/folder not found.');
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idisAbsolute
Table Row (tr)
idname
Table Cell (td)

isAbsolute

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
isAbsolute
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns true if the path is absolute. The path is absolute if it starts with '/' on Unix/Linux/MacOS or has a driver letter on Windows - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('./big.jpg');
// or for a remote file:
// var f = plugins.convertToRemoteJSFile('/images/big.jpg');
if (f && f.exists()) {
	application.output('is absolute: ' + f.isAbsolute());
	application.output('is dir: ' + f.isDirectory());
	application.output('is file: ' + f.isFile());
	application.output('is hidden: ' + f.isHidden());
	application.output('can read: ' + f.canRead());
	application.output('can write: ' + f.canWrite());
	application.output('last modified: ' + f.lastModified());
	application.output('name: ' + f.getName());
	application.output('path: ' + f.getPath());
	application.output('absolute path: ' + f.getAbsolutePath());
	application.output('content type: ' + f.getContentType());
	application.output('size: ' + f.size());
}
else {
	application.output('File/folder not found.');
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idisDirectory
Table Row (tr)
idname
Table Cell (td)

isDirectory

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
isDirectory
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns true if the file is a directory - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('./big.jpg');
// or for a remote file:
// var f = plugins.convertToRemoteJSFile('/images/big.jpg');
if (f && f.exists()) {
	application.output('is absolute: ' + f.isAbsolute());
	application.output('is dir: ' + f.isDirectory());
	application.output('is file: ' + f.isFile());
	application.output('is hidden: ' + f.isHidden());
	application.output('can read: ' + f.canRead());
	application.output('can write: ' + f.canWrite());
	application.output('last modified: ' + f.lastModified());
	application.output('name: ' + f.getName());
	application.output('path: ' + f.getPath());
	application.output('absolute path: ' + f.getAbsolutePath());
	application.output('content type: ' + f.getContentType());
	application.output('size: ' + f.size());
}
else {
	application.output('File/folder not found.');
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idisFile
Table Row (tr)
idname
Table Cell (td)

isFile

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
isFile
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns true if the file is a file and not a regular file - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('./big.jpg');
// or for a remote file:
// var f = plugins.convertToRemoteJSFile('/images/big.jpg');
if (f && f.exists()) {
	application.output('is absolute: ' + f.isAbsolute());
	application.output('is dir: ' + f.isDirectory());
	application.output('is file: ' + f.isFile());
	application.output('is hidden: ' + f.isHidden());
	application.output('can read: ' + f.canRead());
	application.output('can write: ' + f.canWrite());
	application.output('last modified: ' + f.lastModified());
	application.output('name: ' + f.getName());
	application.output('path: ' + f.getPath());
	application.output('absolute path: ' + f.getAbsolutePath());
	application.output('content type: ' + f.getContentType());
	application.output('size: ' + f.size());
}
else {
	application.output('File/folder not found.');
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idisHidden
Table Row (tr)
idname
Table Cell (td)

isHidden

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
isHidden
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns true if the file is hidden (a file system attribute) - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('./big.jpg');
// or for a remote file:
// var f = plugins.convertToRemoteJSFile('/images/big.jpg');
if (f && f.exists()) {
	application.output('is absolute: ' + f.isAbsolute());
	application.output('is dir: ' + f.isDirectory());
	application.output('is file: ' + f.isFile());
	application.output('is hidden: ' + f.isHidden());
	application.output('can read: ' + f.canRead());
	application.output('can write: ' + f.canWrite());
	application.output('last modified: ' + f.lastModified());
	application.output('name: ' + f.getName());
	application.output('path: ' + f.getPath());
	application.output('absolute path: ' + f.getAbsolutePath());
	application.output('content type: ' + f.getContentType());
	application.output('size: ' + f.size());
}
else {
	application.output('File/folder not found.');
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idlastModified
Table Row (tr)
idname
Table Cell (td)

lastModified

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Date
Span
stylefont-weight: bold;
lastModified
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns the time/date of the last modification on the file - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Date
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('./big.jpg');
// or for a remote file:
// var f = plugins.convertToRemoteJSFile('/images/big.jpg');
if (f && f.exists()) {
	application.output('is absolute: ' + f.isAbsolute());
	application.output('is dir: ' + f.isDirectory());
	application.output('is file: ' + f.isFile());
	application.output('is hidden: ' + f.isHidden());
	application.output('can read: ' + f.canRead());
	application.output('can write: ' + f.canWrite());
	application.output('last modified: ' + f.lastModified());
	application.output('name: ' + f.getName());
	application.output('path: ' + f.getPath());
	application.output('absolute path: ' + f.getAbsolutePath());
	application.output('content type: ' + f.getContentType());
	application.output('size: ' + f.size());
}
else {
	application.output('File/folder not found.');
}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idlist
Table Row (tr)
idname
Table Cell (td)

list

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
String[]
Span
stylefont-weight: bold;
list
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns an array of strings naming the files and directories located inside the file, if the file is a directory - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String[]
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var d = plugins.file.convertToJSFile('plugins');
// or for a remote file:
// var d = plugins.convertToRemoteJSFile('/plugins');
var names = d.list();
application.output('Names:');
for (var i=0; i<names.length; i++)
	application.output(names[i]);
var files = d.listFiles();
application.output('Absolute paths:');
for (var i=0; i<files.length; i++)
	application.output(files[i].getAbsolutePath());
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idlistFiles
Table Row (tr)
idname
Table Cell (td)

listFiles

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
JSFile[]
Span
stylefont-weight: bold;
listFiles
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns an array of JSFiles naming the files and directories located inside the file, if the file is a directory - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
JSFile[]
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var d = plugins.file.convertToJSFile('plugins');
// or for a remote file:
// var d = plugins.convertToRemoteJSFile('/plugins');
var names = d.list();
application.output('Names:');
for (var i=0; i<names.length; i++)
	application.output(names[i]);
var files = d.listFiles();
application.output('Absolute paths:');
for (var i=0; i<files.length; i++)
	application.output(files[i].getAbsolutePath());
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idmkdir
Table Row (tr)
idname
Table Cell (td)

mkdir

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
mkdir
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Creates a directory on disk if possible. Returns true if a new directory was created - for remote, use the streamFilesToServer to create the directory instead.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('one/two/three/four');
f.mkdirs(); // Create all four levels of folders in one step.
var g = plugins.file.convertToJSFile('one/two/three/four/five');
g.mkdir(); // This will work because all parent folders are already created.
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idmkdirs
Table Row (tr)
idname
Table Cell (td)

mkdirs

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
mkdirs
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Creates a directory on disk, together with all its parent directories, if possible. Returns true if the hierarchy of directories is created - for remote, use the streamFilesToServer to create the directories instead.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('one/two/three/four');
f.mkdirs(); // Create all four levels of folders in one step.
var g = plugins.file.convertToJSFile('one/two/three/four/five');
g.mkdir(); // This will work because all parent folders are already created.
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idrenameTo-Object
Table Row (tr)
idname
Table Cell (td)

renameTo

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
renameTo
Span
(destination)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Renames the file to a different name. Returns true if the file could be renamed - works on remote files too.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Object} destination
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('story.txt');
f.renameTo('otherstory.txt');
// or for a remote file:
// var f = plugins.convertToRemoteJSFile('/story.txt');
// f.renameTo('/otherstory.txt');
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idsetBytes-byteArray
Table Row (tr)
idname
Table Cell (td)

setBytes

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
setBytes
Span
(bytes)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Set the content of the file (local or remote) to the bytes provided<br/>
Will not create a new file if one doesn't exist
Table Row (tr)
idsnc
Table Cell (td)

Since

Div
classsIndent
5.2.5
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{byte[]} bytes - the data
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean - true if the operation worked
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var file = plugins.file.convertToJSFile('/pathTo/file.jpg');
// or for a remote file:
// var file = plugins.file.convertToRemoteJSFile('/remotePathTo/file.jpg');
var success = file.setBytes(blobDataProvider, true);
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idsetBytes-byteArray_Boolean
Table Row (tr)
idname
Table Cell (td)

setBytes

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
setBytes
Span
(bytes, createFile)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Set the content of the file (local or remote) to the bytes provided
Table Row (tr)
idsnc
Table Cell (td)

Since

Div
classsIndent
5.2.5
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{byte[]} bytes - the data
{Boolean} createFile - true to create a file if it doesn't exist
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean - true if the operation worked
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var file = plugins.file.convertToJSFile('/pathTo/file.jpg');
// or for a remote file:
// var file = plugins.file.convertToRemoteJSFile('/remotePathTo/file.jpg');
var success = file.setBytes(blobDataProvider, true);
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idsetLastModified-Object
Table Row (tr)
idname
Table Cell (td)

setLastModified

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
setLastModified
Span
(date)
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Sets the date/time of the last modification on the file.
Table Row (tr)
idprs
Table Cell (td)

Parameters

Div
classsIndent
{Object} date
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('story.txt');
f.createNewFile();
// Make the file look old.
f.setLastModified(new Date(1999, 5, 21));
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idsetReadOnly
Table Row (tr)
idname
Table Cell (td)

setReadOnly

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Boolean
Span
stylefont-weight: bold;
setReadOnly
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Sets the readonly attribute of the file/directory. Returns true on success.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Boolean
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('invoice.txt');
plugins.file.writeTXTFile(f, 'important data that should not be changed');
f.setReadOnly();
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idsize
Table Row (tr)
idname
Table Cell (td)

size

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
Number
Span
stylefont-weight: bold;
size
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns the size in bytes of the file. Returns 0 if the file does not exist on disk - works on remote files too.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var f = plugins.file.convertToJSFile('./big.jpg');
// or for a remote file:
// var f = plugins.convertToRemoteJSFile('/images/big.jpg');
if (f && f.exists()) {
	application.output('is absolute: ' + f.isAbsolute());
	application.output('is dir: ' + f.isDirectory());
	application.output('is file: ' + f.isFile());
	application.output('is hidden: ' + f.isHidden());
	application.output('can read: ' + f.canRead());
	application.output('can write: ' + f.canWrite());
	application.output('last modified: ' + f.lastModified());
	application.output('name: ' + f.getName());
	application.output('path: ' + f.getPath());
	application.output('absolute path: ' + f.getAbsolutePath());
	application.output('content type: ' + f.getContentType());
	application.output('size: ' + f.size());
}
else {
	application.output('File/folder not found.');
}
Table Row (tr)
classlastDetailRow
Table Cell (td) 2Methods DetailscanReadname

canRead()

dessIndent
Returns true if the file exists and is readable (has access to it) - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
canWritename

canWrite()

dessIndent
Returns true if the file exists and can be modified - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
createNewFilename

createNewFile()

dessIndent
Creates the file on disk if needed. Returns true if the file (name) did not already exists and had to be created - for remote, use the streamFilesToServer to stream a file.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
deleteFilename

deleteFile()

dessIndent
Deletes the file from the disk if possible. Returns true if the file could be deleted. If the file is a directory, then it must be empty in order to be deleted - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
existsname

exists()

dessIndent
Returns true if the file/directory exists on the filesystem - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
getAbsoluteFilename

getAbsoluteFile()

dessIndent
Returns a JSFile instance that corresponds to the absolute form of this pathname - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
getAbsolutePathname

getAbsolutePath()

dessIndent
Returns a String representation of the absolute form of this pathname - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
getBytesname

getBytes()

dessIndent
Gets the contents (bytes) for the file data.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
getContentTypename

getContentType()

dessIndent
Returns the contenttype of this file, like for example 'application/pdf' - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
getNamename

getName()

dessIndent
Returns the name of the file. The name consists in the last part of the file path - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
getParentname

getParent()

dessIndent
Returns the String representation of the path of the parent of this file - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
getParentFilename

getParentFile()

dessIndent
Returns a JSFile instance that corresponds to the parent of this file - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
getPathname

getPath()

dessIndent
Returns a String holding the path to the file - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
isAbsolutename

isAbsolute()

dessIndent
Returns true if the path is absolute. The path is absolute if it starts with '/' on Unix/Linux/MacOS or has a driver letter on Windows - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
isDirectoryname

isDirectory()

dessIndent
Returns true if the file is a directory - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
isFilename

isFile()

dessIndent
Returns true if the file is a file and not a regular file - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
isHiddenname

isHidden()

dessIndent
Returns true if the file is hidden (a file system attribute) - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
lastModifiedname

lastModified()

dessIndent
Returns the time/date of the last modification on the file - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
listname

list()

dessIndent
Returns an array of strings naming the files and directories located inside the file, if the file is a directory - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
listFilesname

listFiles()

dessIndent
Returns an array of JSFiles naming the files and directories located inside the file, if the file is a directory - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
mkdirname

mkdir()

dessIndent
Creates a directory on disk if possible. Returns true if a new directory was created - for remote, use the streamFilesToServer to create the directory instead.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
mkdirsname

mkdirs()

dessIndent
Creates a directory on disk, together with all its parent directories, if possible. Returns true if the hierarchy of directories is created - for remote, use the streamFilesToServer to create the directories instead.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
renameToname

renameTo(destination)

dessIndent
Renames the file to a different name. Returns true if the file could be renamed - works on remote files too.
prs

Parameters

sIndentdestination ;
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
setBytesname

setBytes(bytes)

dessIndent
Set the content of the file (local or remote) to the bytes provided<br/>
Will not create a new file if one doesn't exist
prs

Parameters

sIndentbytesthe data
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
setBytesname

setBytes(bytes, createFile)

dessIndent
Set the content of the file (local or remote) to the bytes provided
prs

Parameters

sIndentbytesthe datacreateFiletrue to create a file if it doesn't exist
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
setLastModifiedname

setLastModified(date)

dessIndent
Sets the date/time of the last modification on the file.
prs

Parameters

sIndentdate ;
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
setReadOnlyname

setReadOnly()

dessIndent
Sets the readonly attribute of the file/directory. Returns true on success.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow
sizename

size()

dessIndent
Returns the size in bytes of the file. Returns 0 if the file does not exist on disk - works on remote files too.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient
sam

Sample

sIdentjavascript
lastDetailRow