Skip to content
Nuno Aguiar edited this page Dec 29, 2017 · 2 revisions

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.fileExists

io.fileExists(aFilename) : boolean

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


io.fileInfo

io.fileInfo(aFilePath)

Returns a file map with filename, filepath, lastModified, createTime, lastAccess,  size, permissions, isDirectory and isFile.


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) : JavaStream

Creates and returns a JavaStream to write to a gzip aFilename. 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) : JavaStream

Creates and returns a JavaStream to write to aFilename. 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, aJSONobject, 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.

Clone this wiki locally