<!--
DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY, UNLESS YOU KNOW WHAT YOU'RE DOING.
THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO EXTRACT CHANGES FROM THE PAGE AND MERGE THEM BACK INTO SERVOY SOURC-->
{column:padding=0px|width=80px}{column}{column}{column}
Method Summery
createNewFile()
Creates the file on disk if needed.
deleteFile()
Deletes the file from the disk if possible.
getAbsoluteFile()
Returns a JSFile instance that corresponds to the absolute form of this pathname - works on remote files too.
getAbsolutePath()
Returns a String representation of the absolute form of this pathname - works on remote files too.
getContentType()
Returns the contenttype of this file, like for example 'application/pdf' - works on remote files too.
getParentFile()
Returns a JSFile instance that corresponds to the parent of this file - works on remote files too.
isAbsolute()
Returns true if the path is absolute.
isDirectory()
Returns true if the file is a directory - works on remote files too.
lastModified()
Returns the time/date of the last modification on the file - works on remote files too.
setLastModified(date)
Sets the date/time of the last modification on the file.
setReadOnly()
Sets the readonly attribute of the file/directory.
{column:padding=0px|width=100%}{column}
Method Details
canRead
()
Returns true if the file exists and is readable (has access to it) - works on remote files too.
Since
Replace with version info
Parameters
Returns
[Boolean]
Also see
External links
Sample
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.'); }
canWrite
()
Returns true if the file exists and can be modified - works on remote files too.
Since
Replace with version info
Parameters
Returns
[Boolean]
Also see
External links
Sample
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.'); }
createNewFile
()
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.
Since
Replace with version info
Parameters
Returns
[Boolean]
Also see
External links
Sample
var f = plugins.file.convertToJSFile('story.txt'); if (!f.exists()) f.createNewFile();
deleteFile
()
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.
Since
Replace with version info
Parameters
Returns
[Boolean]
Also see
External links
Sample
var f = plugins.file.convertToJSFile('story.txt'); // or for a remote file: // var f = plugins.convertToRemoteJSFile('/story.txt'); if (f && f.exists()) f.deleteFile();
exists
()
Returns true if the file/directory exists on the filesystem - works on remote files too.
Since
Replace with version info
Parameters
Returns
[Boolean]
Also see
External links
Sample
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.'); }
getAbsoluteFile
()
Returns a JSFile instance that corresponds to the absolute form of this pathname - works on remote files too.
Since
Replace with version info
Parameters
Returns
[JSFile]
Also see
External links
Sample
var f = plugins.file.convertToJSFile('story.txt'); // or for a remote file: // var f = plugins.convertToRemoteJSFile('/story.txt'); application.output('parent folder: ' + f.getAbsoluteFile().getParent()); application.output('parent folder has ' + f.getAbsoluteFile().getParentFile().listFiles().length + ' entries');
getAbsolutePath
()
Returns a String representation of the absolute form of this pathname - works on remote files too.
Since
Replace with version info
Parameters
Returns
[String]
Also see
External links
Sample
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.'); }
byte[]
getBytes
()
Replace with description
Since
Replace with version info
Parameters
Returns
byte[]
Also see
External links
Sample
getContentType
()
Returns the contenttype of this file, like for example 'application/pdf' - works on remote files too.
Since
Replace with version info
Parameters
Returns
[String]
Also see
External links
Sample
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.'); }
getName
()
Returns the name of the file. The name consists in the last part of the file path - works on remote files too.
Since
Replace with version info
Parameters
Returns
[String]
Also see
External links
Sample
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.'); }
getParent
()
Returns the String representation of the path of the parent of this file - works on remote files too.
Since
Replace with version info
Parameters
Returns
[String]
Also see
External links
Sample
var f = plugins.file.convertToJSFile('story.txt'); // or for a remote file: // var f = plugins.convertToRemoteJSFile('/story.txt'); application.output('parent folder: ' + f.getAbsoluteFile().getParent()); application.output('parent folder has ' + f.getAbsoluteFile().getParentFile().listFiles().length + ' entries');
getParentFile
()
Returns a JSFile instance that corresponds to the parent of this file - works on remote files too.
Since
Replace with version info
Parameters
Returns
[JSFile]
Also see
External links
Sample
var f = plugins.file.convertToJSFile('story.txt'); // or for a remote file: // var f = plugins.convertToRemoteJSFile('/story.txt'); application.output('parent folder: ' + f.getAbsoluteFile().getParent()); application.output('parent folder has ' + f.getAbsoluteFile().getParentFile().listFiles().length + ' entries');
getPath
()
Returns a String holding the path to the file - works on remote files too.
Since
Replace with version info
Parameters
Returns
[String]
Also see
External links
Sample
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.'); }
isAbsolute
()
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.
Since
Replace with version info
Parameters
Returns
[Boolean]
Also see
External links
Sample
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.'); }
isDirectory
()
Returns true if the file is a directory - works on remote files too.
Since
Replace with version info
Parameters
Returns
[Boolean]
Also see
External links
Sample
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.'); }
isFile
()
Returns true if the file is a file and not a regular file - works on remote files too.
Since
Replace with version info
Parameters
Returns
[Boolean]
Also see
External links
Sample
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.'); }
isHidden
()
Returns true if the file is hidden (a file system attribute) - works on remote files too.
Since
Replace with version info
Parameters
Returns
[Boolean]
Also see
External links
Sample
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.'); }
lastModified
()
Returns the time/date of the last modification on the file - works on remote files too.
Since
Replace with version info
Parameters
Returns
[Date]
Also see
External links
Sample
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.'); }
String[]
list
()
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.
Since
Replace with version info
Parameters
Returns
[String][]
Also see
External links
Sample
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());
JSFile[]
listFiles
()
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.
Since
Replace with version info
Parameters
Returns
[JSFile][]
Also see
External links
Sample
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());
mkdir
()
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.
Since
Replace with version info
Parameters
Returns
[Boolean]
Also see
External links
Sample
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.
mkdirs
()
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.
Since
Replace with version info
Parameters
Returns
[Boolean]
Also see
External links
Sample
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.
renameTo
(destination)
Renames the file to a different name. Returns true if the file could be renamed - works on remote files too.
Since
Replace with version info
Parameters
destination
Returns
[Boolean]
Also see
External links
Sample
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');
setLastModified
(date)
Sets the date/time of the last modification on the file.
Since
Replace with version info
Parameters
date
Returns
[Boolean]
Also see
External links
Sample
var f = plugins.file.convertToJSFile('story.txt'); f.createNewFile(); // Make the file look old. f.setLastModified(new Date(1999, 5, 21));
setReadOnly
()
Sets the readonly attribute of the file/directory. Returns true on success.
Since
Replace with version info
Parameters
Returns
[Boolean]
Also see
External links
Sample
var f = plugins.file.convertToJSFile('invoice.txt'); plugins.file.writeTXTFile(f, 'important data that should not be changed'); f.setReadOnly();
Returns the size in bytes of the file. Returns 0 if the file does not exist on disk - works on remote files too.
Since
Replace with version info
Parameters
Returns
[Number]
Also see
External links
Sample
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.'); }