iocore

io.convertFileToEncoding

io.convertFileToEncoding(aOriginalFile, aNewFile, anEncoding)

Converts an original file into a new file using the provided enconding.

io.cp

io.cp(aSourceFilePath, aTargetFilePath)

Tries to copy aSourceFilePath to aTargetFilePath preserving file attributes.

io.createTempDir

io.createTempDir(aPrefix, aPath) : String

Creates a temporary directory with the provided aPrefix that will be deleted completly (all files and folders inside) upon execution exit. The absolute path for it is returned. Optionally, if aPath is defined, the temporary directory will be created in aPath.

io.createTempFile

io.createTempFile(aPrefix, aSuffix, aPath) : String

Creates a temporary file with the provided aPrefix and aSuffix that will be deleted upon execution exit. The absolute path for it is returned. Optionally, if aPath is defined, the temporary file will be created in aPath.

io.fileExists

io.fileExists(aFilename) : boolean

Returns true or false to determine if aFilename exists on the filesystem.

io.fileInfo

io.fileInfo(aFilePath, usePosix)

Returns a file map with filename, filepath, lastModified, createTime, lastAccess,  size, permissions, isDirectory and isFile. Alternatively you can specify to usePosix=true and it will add to the map the owner, group and full permissions of each file and folder.

io.getCanonicalPath

io.getCanonicalPath(aPath) : String

Returns the canonical path for the provided aPath either if the file/folder exists or not.

io.getDefaultEncoding

io.getDefaultEncoding()

Returns the current default encoding used.

io.getFileEncoding

io.getFileEncoding(aFile)

Tries to determine the file encoding of a given file and returns the same.

io.gunzip

io.gunzip(anArrayOfBytes) : anObject

Uncompresses a gziped array of bytes.

io.gzip

io.gzip(anObject) : anArrayOfBytes

Compresses an object into an array of bytes.

io.listFilenames

io.listFilenames(aFilePath, fullPath)

Returns a files array with a map with filepath (if fullPath = true) or filename otherwise.

io.listFiles

io.listFiles(aFilePath, usePosix)

Returns a files array with a map with filename, filepath, lastModified, createTime, lastAccess,  size, permissions, isDirectory and isFile for each entry on a file path. Alternatively you can specify to usePosix=true and it will add to the map the owner, group and full permissions of each file and folder.

io.mkdir

io.mkdir(aNewDirectory) : boolean

Tries to create aNewDirectory. Returns true if successfull, false otherwise.

io.mv

io.mv(aSourceFilePath, aTargetFilePath)

Tries to move aSourceFilePath to aTargetFilePath preserving file attributes.

io.randomAccessFile

io.randomAccessFile(aFilename, aMode) : RandomAccessFile

Creates a java RandomAccessFile to enable random access to files and returns the same.

io.readFile

io.readFile(aFilename, anEncoding)

Reads a file auto detecting between JSON, ParameterMap, PMap and configuration PMap, optionally providing an encoding.
Note: aFilename can contain "a.zip::afile" to read from zip files.

io.readFileAsArray

io.readFileAsArray(aFilename, anEncoding)

Reads a file, optionally providing a specific encoding to use, and returns an array where each  line is an array element.

io.readFileBytes

io.readFileBytes(aFilename)

Reads a file into an array of bytes.
Note: aFilename can contain "a.zip::afile" to read from zip files.

io.readFileGzipStream

io.readFileGzipStream(aFilename) : JavaStream

Creates and returns a JavaStream to read from a gzip aFilename. For example:

var stream = io.readFileGzipStream("afile.txt.gz");
ioStreamRead(stream, function(buffer) { // you can also use ioStreamReadBytes 
   printnl(buffer);
});
stream.close();


io.readFileStream

io.readFileStream(aFilename) : JavaStream

Creates and returns a JavaStream to read aFilename. For example:

var stream = io.readFileStream("afile.txt");
ioStreamRead(stream, function(buffer) { // you can also use ioStreamReadBytes 
   printnl(buffer);
});
stream.close();


io.readFileString

io.readFileString(aFilename, anEncoding)

Reads a file, optionally providing a specific encoding to use, and returns a string with the entire contents of the file.
Note: aFilename can contain "a.zip::afile" to read from zip files.

io.readFileXML

io.readFileXML(aFilename, numOfLinesToSkip, anEncoding)

Reads a file, optionally providing a specific encoding to use and/or the number of lines to skip (e.g. 1 to exclude the xml main header) and returns the contents in a XML object.
Note: aFilename can contain "a.zip::afile" to read from zip files.

io.rename

io.rename(aSourceFilePath, aTargetFilePath)

Tries to rename aSourceFilePath to aTargetFilePath.

io.rm

io.rm(aFilePath)

Tries to delete a file or a directory on the provided aFilePath. In case it's a directory it will try to  recursively delete all directory contents.

io.writeFile

io.writeFile(aFilename, aJSONobject, anEncoding, shouldAppend)

Writes a JSON object into the given filename, optionally with the provided encoding and/or determine if it shouldAppend to an existing file.

io.writeFileAsArray

io.writeFileAsArray(aFilename, anArrayOfLines, anEncoding)

Writes an array of string lines into a file, optionally with the provided encoding

io.writeFileBytes

io.writeFileBytes(aFilename, anArrayOfBytes)

Writes an array of bytes into the given filename.

io.writeFileGzipStream

io.writeFileGzipStream(aFilename, shouldAppend) : JavaStream

Creates and returns a JavaStream to write to a gzip aFilename. Optionally if shouldAppend=true it will append to an existing file. For example:

var stream = io.writeFileGzipStream("afile.txt.gz");
ioStreamWrite(stream, "Hello "); // you can also use ioStreamWriteBytes 
ioStreamWrite(stream, "World!");
stream.close();


io.writeFileStream

io.writeFileStream(aFilename, shouldAppend) : JavaStream

Creates and returns a JavaStream to write to aFilename. If shouldAppend = true the stream will  append to the existing file. For example:

var stream = io.writeFileStream("afile.txt");
ioStreamWrite(stream, "Hello "); // you can also use ioStreamWriteBytes 
ioStreamWrite(stream, "World!");
stream.close();


io.writeFileString

io.writeFileString(aFilename, aString, anEncoding, shouldAppend)

Writes a string into the given filename, optionally with the provided encoding and/or determine if it shouldAppend to an existing file.

io.writeFileXML

io.writeFileXML(aFilename, aXMLobject, anEncoding, shouldAppend)

Writes a XML object into the given filename, optionally with the provided encoding and/or determine if it shouldAppend to an existing file.