FileUtil

getFileExtension

Returns the extension of the file.

FileUtil.getFileExtension(fileName)

Parameters

fileName (string)

Returns

The extension of the file.

copyFile

Copies a file from the source path to the destination path while preserving the metadata.

FileUtil.copyFile(in, out)

Parameters

in (File)
out (File)

Returns

None

renameTo

Renames a file or directory.

renameTo.renameTo(fromFile, toFile)

Parameters

fromFile (File)
toFile (File)

Returns

None

readFile

Scans through a file and reads all the lines

FileUtil.readFile(file, numberOfLines)

Parameters

file (File)
numberOfLines (int)

Returns

The content of the file.

writeFile

Writes content to a file.

FileUtil.writeFile(file, buf)

or

FileUtil.writeFile(file, bytes)

Parameters

file (File)
buf (string)
bytes (List of bytes)

Returns

None

getFileTimestamp

Gets the timestamp of the last modification of a file.

FileUtil.getFileTimestamp(f)

Parameters

f (File)

Returns

The timestamp of the last modification of the file.

isFileModifiedBefore

Checks if the file was modified before the provided timestamp

FileUtil.isFileModifiedBefore(f, ts)

Parameters

f (File)
ts (float)

Returns

True if the file has been modified before the specified timestamp; otherwise, False.

isFileModifiedBeforeDelta

Checks if a file has been modified before a specified timestamp with a given delta.

FileUtil.isFileModifiedBeforeDelta(f, ts, delta)

Parameters

inputFile (File)
Timestamp (float)
delta (float)

Returns

True if the file has been modified before the specified timestamp with a difference greater than the delta; otherwise, False.

getFileBufferedReader

Description...

FileUtil.getFileBufferedReader(file)

Parameters

inputFile (File)

Returns

BufferedReader

getUniqueFileName

Generates a unique file name by appending a numerical suffix to the given prefix.

FileUtil.getUniqueFileName(dirName, fileName)
or
FileUtil.(dirName, fileNamePrefix, ext)

Parameters

dirName (string)
fileName (string)
fileNamePrefix (string)
ext (string)

Returns

A unique file name within the specified directory.

getFileList

Description...

FileUtil.getFileList(path, fileExtensions)

Parameters

path (string)
fileExtensions (string)

Returns

List of files

getFileListNonRecursive

Description...

FileUtil.getFileListNonRecursive(path, extensions)

Parameters

path (string)
extensions (List of strings)

Returns

List of files

getFile

Description...

FileUtil.getFile(file)

Parameters

file (File)

Returns

Resource

copyTextFile

Copies a text file from the source path to the destination path.

FileUtil.copyTextFile(file1, file2)

Parameters

file1 (File)
file2 (File)

Returns

None

isResizableImageFile

Description...

FileUtil.isResizableImageFile(fileName)

Parameters

fileName (string)

Returns

boolean

getSupportedFileTypes

Description...

FileUtil.getSupportedFileTypes()

Parameters

None

Returns

String

RemoveTemp

Description...

FileUtil.RemoveTemp(workDir)

Parameters

workDir (File)

Returns

boolean

RemoveTemp

Description...

FileUtil.RemoveTemp(workDir)

Parameters

workDir (File)

Returns

boolean

RemoveTemp

Description...

FileUtil.RemoveTemp(workDir)

Parameters

workDir (File)

Returns

boolean

takeOffBOM

Description...

FileUtil.takeOffBOM(str)

Parameters

str (string)

Returns

String

listDirectory

Description...

FileUtil.listDirectory(String repoRoot, File directory,
      int timeLimit)

Parameters

repoRoot (string)
directory (File)
timeLimit (int)

Returns

List of dictionaries

listDirectory

Description...

FileUtil.validateFilePath(file)

Parameters

file (File)

Returns

None

validateFilePath

Description...

FileUtil.validateFilePath(parent, file)

Parameters

parent (string)
file (File)

Returns

None

validateFilePath

Description...

validateFilePath(parentDir, file)

Parameters

parentDir (string)
file (File)

Returns

None

Last updated