1 File

Class Ax.io.File


Wrapper around java.io.File class, which is an abstract representation of file and directory pathnames.

Constructor Summary

MethodDescription
JSFile()Creates a new instance pointing to the directory where the server starts.
JSFile(File file)Creates a new instance from the given File.
JSFile(JSFile file, String name)Creates a new instance: 1.
JSFile(String name)Creates a new instance pointing to the specified path.
JSFile(String path, String name)Creates a new instance specifying a parent path and a file name.

Method Summary

Modifier and TypeMethodDescription
long append(byte[] data)Appends a byte[] to file, creating the file if it doesn't exist.
void append(String text)Appends a text as UTF-8, creating the file if doesn't exist.
void append(String text, String charsetName)Appends the given text with UTF-8 encoding, ignoring the given charset.
void append(String text, String charsetName, boolean ignoreErrors)Appends the given text with the specified encoding.
byte[] asBytes()Return the file as byte[].
String asString()Return the file as UTF-8 String.
String asText()Return the file as UTF-8 String.
boolean canExecute()Checks whether user has execute permission on the file.
boolean canRead()Checks whether user has read permission on the file.
boolean canWrite()Checks whether user has write permission on the file.
int compareTo(JSFile o)Compares lexicographically 2 pathnames.
JSFile createTempFile()Creates a new temporary file (.
JSFile createTempFile(String tempName)Creates a new temporary file (.
JSFile createTempFolder()Allows creating a temp folder which will be automatically deleted on exit, inside the application temporary folder:
JSFile createTempFolder(String tempName)Allows creating a named temp folder which will be automatically deleted on exit, inside the application temporary folder:
boolean delete()Deletes the file / directory.
boolean exists()Checks if file / directory defined by the pathname exists.
String getAbsolutePath()Returns the absolute form of this abstract pathname.
String getContentType()Returns the file content type according "https://www.
long getCreationTime()Returns the creation time in milliseconds since the epoch (1970-01-01T00:00:00Z).
long getFreeSpace()Returns the number of unallocated bytes in the partition by this abstract path name.
long getLastAccessTime()Returns the time of last access in milliseconds since the epoch (1970-01-01T00:00:00Z).
long getLastModified()Returns the time of last modification in milliseconds since the epoch (1970-01-01T00:00:00Z).
long getLineCount()Returns the count of lines from a file.
String getName()Returns the name of the file or directory (last name in the pathname).
String getNameTo(String separator)Given a temp file like: /var/folders/h1/chsft9sj5pz64g45lmfbwdym0000gn/T/axional-863/JSFile/abc-13452678154332861398.
JSFile getParentFile()Returns the parent file abstract pathname.
boolean isDirectory()Checks whether the file denoted by this abstract pathname is a directory file.
boolean isFile()Checks whether the file denoted by this abstract pathname is a normal file.
long lastModified()Returns the time that the file denoted by this abstract pathname was last modified.
long length()Returns the length of the file denoted by this abstract pathname.
List list()Returns a list of strings naming the files and directories in the directory denoted by this abstract pathname.
List listFiles()Returns a list of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
List listFiles(Function<JSFileBoolean> filter)Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
boolean mkdir()Creates yhe directory defined by the pathname.
boolean mkdirs()Creates he directory defined by the pathname, and all the necessary paretn directories.
byte[] readBytes()Reads all the bytes from a file.
String readString()Reads all content from a file into a string, decoding from bytes to characters using UTF8 charset.
String readString(String charsetName)Reads all content from a file into a string, decoding from bytes to characters using UTF8 charset.
String readString(String charsetName, boolean ignoreErrors)Reads all content from a file into a string, decoding from bytes to characters using UTF8 charset.
boolean renameTo(JSFile file)Renames the file denoted by this abstract pathname.
boolean renameTo(String name)Renames the file denoted by this abstract pathname, taking into account relative or absolute directories.
List split(int linesPerSplit)The purpose of File.
JDBCBlob toBlob()Saves the file de noted by the pathname as a BLOB.
InputStream toInputStream()Returns a new FileInputStream of the file.
Reader toReader()Returns a new FileReader of the file.
Reader toReader(String charsetName)Returns a new FileReader of the file, using thespecified charset WARNING: Available since JDK 10
String toString()Returns a String with the path of the file.
Writer toWriter()Returns a new FileWriter of the file.
long write(Blob data)Writes the data into the file denoted by the pathname.
long write(byte[] data)Writes the data into the file denoted by the pathname.
long write(IBlobConvertible data)Writes the data into the file denoted by the pathname.
void write(String text)Writes the text into the file denoted by the pathname, using UTF8 charset.
void write(String text, String charsetName)Writes the text into the file denoted by the pathname, using the specified charset.
void write(String text, String charsetName, boolean ignoreErrors)Writes the text into the file denoted by the pathname, using the specified charset.

Method Detail

JSFile

 JSFile()
Info:
Creates a new instance pointing to the directory where the server starts.

JSFile

 JSFile(File file)
Info:
Creates a new instance from the given File.
Parameters:
file - source File

JSFile

 JSFile(JSFile file, String name)
Info:
Creates a new instance: 1. If param 'file' is a directory, creates a new file with he specified name in the directory. 2. If param 'file' is a file, creates a new file with the specified name in the directory of that file.
Parameters:
file - file where the new file will be created
name - name of he new file

Example
Copy
var file1 = new Ax.io.File("/tmp/test1.txt");
 var file2 = new Ax.io.File(file1, "test2.txt")

JSFile

 JSFile(String name)
Info:
Creates a new instance pointing to the specified path.
Parameters:
name - path of the file

JSFile

 JSFile(String path, String name)
Info:
Creates a new instance specifying a parent path and a file name.
Parameters:
path - path of the parent directory
name - name of the file

append

long append(byte[] data)
Info:
Appends a byte[] to file, creating the file if it doesn't exist.
Parameters:
data - data to append
Returns:
the length of the data

append

void append(String text)
Info:
Appends a text as UTF-8, creating the file if doesn't exist.
Parameters:
text - text to append

append

void append(String text, String charsetName)
Info:
Appends the given text with UTF-8 encoding, ignoring the given charset. Creates the file if doesn't exist.
Parameters:
text - text to append
charsetName - character encoding

append

void append(String text, String charsetName, boolean ignoreErrors)
Info:
Appends the given text with the specified encoding. 'ignoreErrors' specifies if the encoding errors between source and destination file will be ignored. Creates the file if doesn't exist.
Parameters:
text - text to append
charsetName - character encoding
ignoreErrors - true to ignore errors, false otherwise

asBytes

byte[] asBytes()
Info:
Return the file as byte[].
Returns:
the file as byte[]

asString

                        String asString()
Info:
Return the file as UTF-8 String.
Returns:
the file as UTF-8 String

asText

                        String asText()
Info:
Return the file as UTF-8 String. (same to asString)
Returns:
the file as UTF-8 String

canExecute

boolean canExecute()
Info:
Checks whether user has execute permission on the file.
Returns:
true if user has execute permission, false otherwise

canRead

boolean canRead()
Info:
Checks whether user has read permission on the file.
Returns:
true if user has read permission, false otherwise

canWrite

boolean canWrite()
Info:
Checks whether user has write permission on the file.
Returns:
true if user has write permission, false otherwise

compareTo

int compareTo(JSFile o)
Info:
Compares lexicographically 2 pathnames. If they are equal it returns 0, if first is lexicographically less than o, returns a negative value, if first greater than o, returns positive.
Parameters:
o - file pathname to compare to
Returns:

createTempFile

                        JSFile createTempFile()
Info:
Creates a new temporary file (.tmp).
Returns:
the temporary file created

Example
Copy
Ax.io.File.createTempFile();

createTempFile

                        JSFile createTempFile(String tempName)
Info:
Creates a new temporary file (.tmp) with the specified name.
Parameters:
tempName - the name of the temporary file
Returns:
the temporary file created

Example
Copy
Ax.io.File.createTempFile(String tempName);

createTempFolder

                        JSFile createTempFolder()
Info:
Allows creating a temp folder which will be automatically deleted on exit, inside the application temporary folder:
Returns:
the temporary folder

Example
Copy
let tmpFolder = Ax.io.File.createTempFolder();
 console.log(tmpFolder)
 // /home/axs/studio/tmp/axional-80057/JSFile/jsfolder-6616853615518563598

createTempFolder

                        JSFile createTempFolder(String tempName)
Info:
Allows creating a named temp folder which will be automatically deleted on exit, inside the application temporary folder:
Parameters:
tempName - the name of the temporary folder
Returns:
the temporary folder

Example
Copy
let tmpFolder = Ax.io.File.createTempFolder("my_temp_folder");
 console.log(tmpFolder)
 // /home/axs/studio/tmp/axional-80057/JSFile/my_temp_folder-6616853615518563598

delete

boolean delete()
Info:
Deletes the file / directory.
Returns:

exists

boolean exists()
Info:
Checks if file / directory defined by the pathname exists.
Returns:

getAbsolutePath

                        String getAbsolutePath()
Info:
Returns the absolute form of this abstract pathname.
Returns:
the absolute path

getContentType

                        String getContentType()
Info:
Returns the file content type according "https://www.baeldung.com/java-file-mime-type".
Returns:
the file content type according "https://www.baeldung.com/java-file-mime-type"

getCreationTime

long getCreationTime()
Info:
Returns the creation time in milliseconds since the epoch (1970-01-01T00:00:00Z). The creation time is the time that the file was created.
Returns:
the creation time in milliseconds

getFreeSpace

long getFreeSpace()
Info:
Returns the number of unallocated bytes in the partition by this abstract path name.
Returns:
the number of unallocated bytes

getLastAccessTime

long getLastAccessTime()
Info:
Returns the time of last access in milliseconds since the epoch (1970-01-01T00:00:00Z).
Returns:
the time of last access in milliseconds

getLastModified

long getLastModified()
Info:
Returns the time of last modification in milliseconds since the epoch (1970-01-01T00:00:00Z).
Returns:
time of last modification in milliseconds

getLineCount

long getLineCount()
Info:
Returns the count of lines from a file.
Returns:
the count of lines from a file

getName

                        String getName()
Info:
Returns the name of the file or directory (last name in the pathname).
Returns:
the name of the file or directory

getNameTo

                        String getNameTo(String separator)
Info:
Given a temp file like: /var/folders/h1/chsft9sj5pz64g45lmfbwdym0000gn/T/axional-863/JSFile/abc-13452678154332861398.tmp getName() : abc-13452678154332861398.tmp getNameTo("-") : abc
Parameters:
separator - 
Returns:

getParentFile

                        JSFile getParentFile()
Info:
Returns the parent file abstract pathname.
Returns:
the parent file abstract pathname

isDirectory

boolean isDirectory()
Info:
Checks whether the file denoted by this abstract pathname is a directory file.
Returns:
true if directory, false otherwise

isFile

boolean isFile()
Info:
Checks whether the file denoted by this abstract pathname is a normal file.
Returns:
true if directory, false otherwise

lastModified

long lastModified()
Info:
Returns the time that the file denoted by this abstract pathname was last modified.
Returns:

length

long length()
Info:
Returns the length of the file denoted by this abstract pathname. The return value is unspecified if this pathname denotes a directory.
Returns:

list

                        List list()
Info:
Returns a list of strings naming the files and directories in the directory denoted by this abstract pathname.
Returns:
a list of files and directories of the directory

listFiles

                        List listFiles()
Info:
Returns a list of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
Returns:
a list of files of the directory

listFiles

                        List listFiles(Function<JSFileBoolean> filter)
Info:
Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
Parameters:
filter - filter Function
Returns:
a list of files and directories of the directory

mkdir

boolean mkdir()
Info:
Creates yhe directory defined by the pathname.
Returns:
true if the directory has been successfully created, false if there has been any error

mkdirs

boolean mkdirs()
Info:
Creates he directory defined by the pathname, and all the necessary paretn directories.
Returns:
true if the directories have been successfully created, false if there has been any error

readBytes

byte[] readBytes()
Info:
Reads all the bytes from a file. The method ensures that the file is closed when all bytes have been read or an I/O error, or other runtime exception, is thrown.
Returns:
the contents of the file

readString

                        String readString()
Info:
Reads all content from a file into a string, decoding from bytes to characters using UTF8 charset.
Returns:
string with contents of the file

readString

                        String readString(String charsetName)
Info:
Reads all content from a file into a string, decoding from bytes to characters using UTF8 charset.
Parameters:
charsetName - charset to use to interpret the contents of the file
Returns:
string with contents of the file

readString

                        String readString(String charsetName, boolean ignoreErrors)
Info:
Reads all content from a file into a string, decoding from bytes to characters using UTF8 charset. 'ignoreErrors' is used o set if encoding errors will be ignored or not.
Parameters:
charsetName - true to ignore encoding errors, false otherwise
ignoreErrors - true to ignore errors, false otherwise
Returns:
string with contents of the file

renameTo

boolean renameTo(JSFile file)
Info:
Renames the file denoted by this abstract pathname.
Parameters:
file - new name
Returns:
true if the nae has been successfully changed, false if there has been any error

renameTo

boolean renameTo(String name)
Info:
Renames the file denoted by this abstract pathname, taking into account relative or absolute directories. If name contains file separator (/) it's considered absolute. In any other case it's considered relative to us.
Parameters:
name - new name
Returns:
true if the nae has been successfully changed, false if there has been any error

split

                        List split(int linesPerSplit)
Info:
The purpose of File.split function is to split this file into N chunks of up to the "linesPerSplit" parameter. It only has sense for text files (there is no binary equivalent). Output files are generated in temporary directory.
Parameters:
linesPerSplit - 
Returns:
an array of temporary files for the split

toBlob

                        JDBCBlob toBlob()
Info:
Saves the file de noted by the pathname as a BLOB.
Returns:
BLOB containing the file

toInputStream

                        InputStream toInputStream()
Info:
Returns a new FileInputStream of the file.
Returns:
a new FileInputStream

toReader

                        Reader toReader()
Info:
Returns a new FileReader of the file.
Returns:
a new FileReader of the file

toReader

                        Reader toReader(String charsetName)
Info:
Returns a new FileReader of the file, using thespecified charset WARNING: Available since JDK 10
Parameters:
charsetName - charset to use by the reader.
Returns:
a new FileReader of the file

toString

                        String toString()
Info:
Returns a String with the path of the file.
Returns:

toWriter

                        Writer toWriter()
Info:
Returns a new FileWriter of the file.
Returns:
a new FileWriter of the file

write

long write(Blob data)
Info:
Writes the data into the file denoted by the pathname.
Parameters:
data - data to write
Returns:
the number of bytes written

write

long write(byte[] data)
Info:
Writes the data into the file denoted by the pathname.
Parameters:
data - data to write
Returns:
the length of the data

write

long write(IBlobConvertible data)
Info:
Writes the data into the file denoted by the pathname.
Parameters:
data - data to write
Returns:
the number of bytes written

write

void write(String text)
Info:
Writes the text into the file denoted by the pathname, using UTF8 charset.
Parameters:
text - text to write

write

void write(String text, String charsetName)
Info:
Writes the text into the file denoted by the pathname, using the specified charset.
Parameters:
text - text to write
charsetName - charset to use

write

void write(String text, String charsetName, boolean ignoreErrors)
Info:
Writes the text into the file denoted by the pathname, using the specified charset. 'ignoreErrors' is used o set if encoding errors will be ignored or not.
Parameters:
text - text to write
charsetName - charset to use
ignoreErrors - true to ignore errors, false otherwise

2 FileName

Class Ax.io.FileName


Constructor Summary

MethodDescription
JSFileName(JSFile file)
JSFileName(String name)

Method Summary

Modifier and TypeMethodDescription
String getBaseName()Gets the base name, minus the full path and extension, from a full filename.
String getExtension()Gets the extension of a filename.
String getFullPath()Gets the full path from a full filename, which is the prefix + path.
String getFullPathNoEndSeparator()Gets the full path from a full filename, which is the prefix + path, and also excluding the final directory separator.
String getName()Gets the name minus the path from a full filename.
String getPath()Gets the path from a full filename, which excludes the prefix.
String getPathNoEndSeparator()Gets the path from a full filename, which excludes the prefix, and also excluding the final directory separator.
String getPrefix()Gets the prefix from a full filename, such as
int getPrefixLength()Returns the length of the filename prefix, such as
int indexOfExtension(String filename)Returns the index of the last extension separator character, which is a dot.
int indexOfLastSeparator(String filename)Returns the index of the last directory separator character.
boolean isExtension(String extension)Checks whether the extension of the filename is that specified.
boolean isExtension(String[] extensions)Checks whether the extension of the filename is one of those specified.
boolean isExtension(Collection<String> extensions)Checks whether the extension of the filename is one of those specified.
boolean isSystemWindows()Determines if Windows file system is in use.
String normalize()Normalizes a path, removing double and single dot path steps.
String normalize(boolean unixSeparator)Normalizes a path, removing double and single dot path steps.
String normalizeNoEndSeparator()Normalizes a path, removing double and single dot path steps, and removing any final directory separator.
String normalizeNoEndSeparator(boolean unixSeparator)Normalizes a path, removing double and single dot path steps, and removing any final directory separator.
String removeExtension()Removes the extension from a filename.
String separatorsToSystem()Converts all separators to the system separator.
String separatorsToUnix()Converts all separators to the Unix separator of forward slash.
String separatorsToWindows()Converts all separators to the Windows separator of backslash.
String[] splitOnTokens(String text)Splits a string into a number of tokens.
boolean wildcardMatch(String wildcardMatcher)Checks a filename to see if it matches the specified wildcard matcher, always testing case-sensitive.
boolean wildcardMatch(String filename, String wildcardMatcher, IOCase caseSensitivity)Checks a filename to see if it matches the specified wildcard matcher allowing control over case-sensitivity.
boolean wildcardMatchOnSystem(String wildcardMatcher)Checks a filename to see if it matches the specified wildcard matcher using the case rules of the system.

Method Detail

JSFileName

 JSFileName(JSFile file)
Parameters:
file - 

JSFileName

 JSFileName(String name)
Parameters:
name - 

getBaseName

                        String getBaseName()
Info:
Gets the base name, minus the full path and extension, from a full filename.
Returns:
the name of the file without the path, or an empty string if none exists

Example
Copy
This method will handle a file in either Unix or Windows format.
 The text after the last forward or backslash and before the last dot is returned.
 
 a/b/c.txt -- c
 a.txt     -- a
 a/b/c     -- c
 a/b/c/    -- ""

getExtension

                        String getExtension()
Info:
Gets the extension of a filename.
Returns:
the extension of the file or an empty string if none exists or <code> null if the filename is <code> null.

Example
Copy
This method returns the textual part of the filename after the last dot.
 There must be no directory separator after the dot.
 
 foo.txt      -- "txt"
 a/b/c.jpg    -- "jpg"
 a/b.txt/c    -- ""
 a/b/c        -- ""

getFullPath

                        String getFullPath()
Info:
Gets the full path from a full filename, which is the prefix + path.
Returns:
the path of the file, an empty string if none exists, null if invalid

Example
Copy
This method will handle a file in either Unix or Windows format.
 The method is entirely text based, and returns the text before and
 including the last forward or backslash.
 
 C:\a\b\c.txt -- C:\a\b\
 ~/a/b/c.txt  -- ~/a/b/
 a.txt        -- ""
 a/b/c        -- a/b/
 a/b/c/       -- a/b/c/
 C:           -- C:
 C:\          -- C:\
 ~            -- ~/
 ~/           -- ~/
 ~user        -- ~user/
 ~user/       -- ~user/

getFullPathNoEndSeparator

                        String getFullPathNoEndSeparator()
Info:
Gets the full path from a full filename, which is the prefix + path, and also excluding the final directory separator.
Returns:
the path of the file, an empty string if none exists, null if invalid

Example
Copy
This method will handle a file in either Unix or Windows format.
 The method is entirely text based, and returns the text before the
 last forward or backslash.
 
 C:\a\b\c.txt -- C:\a\b
 ~/a/b/c.txt  -- ~/a/b
 a.txt        -- ""
 a/b/c        -- a/b
 a/b/c/       -- a/b/c
 C:           -- C:
 C:\          -- C:\
 ~            -- ~
 ~/           -- ~
 ~user        -- ~user
 ~user/       -- ~user

getName

                        String getName()
Info:
Gets the name minus the path from a full filename.
Returns:
the name of the file without the path, or an empty string if none exists

Example
Copy
This method will handle a file in either Unix or Windows format.
 The text after the last forward or backslash is returned.
 
 a/b/c.txt -- c.txt
 a.txt     -- a.txt
 a/b/c     -- c
 a/b/c/    -- ""

getPath

                        String getPath()
Info:
Gets the path from a full filename, which excludes the prefix.
Returns:
the path of the file, an empty string if none exists, null if invalid

Example
Copy
This method will handle a file in either Unix or Windows format.
 The method is entirely text based, and returns the text before and
 including the last forward or backslash.
 
 C:\a\b\c.txt -- a\b\
 ~/a/b/c.txt  -- a/b/
 a.txt        -- ""
 a/b/c        -- a/b/
 a/b/c/       -- a/b/c/

getPathNoEndSeparator

                        String getPathNoEndSeparator()
Info:
Gets the path from a full filename, which excludes the prefix, and also excluding the final directory separator.
Returns:
the path of the file, an empty string if none exists, null if invalid

Example
Copy
This method will handle a file in either Unix or Windows format.
 The method is entirely text based, and returns the text before the
 last forward or backslash.
 
 C:\a\b\c.txt -- a\b
 ~/a/b/c.txt  -- a/b
 a.txt        -- ""
 a/b/c        -- a/b
 a/b/c/       -- a/b/c

getPrefix

                        String getPrefix()
Info:
Gets the prefix from a full filename, such as
Returns:
the prefix of the file, null if invalid

Example
Copy
C:/
 or ~/.
 This method will handle a file in either Unix or Windows format.
 The prefix includes the first slash in the full filename where applicable.
 
 Windows:
 a\b\c.txt           -- ""          -- relative
 \a\b\c.txt          -- "\"         -- current drive absolute
 C:a\b\c.txt         -- "C:"        -- drive relative
 C:\a\b\c.txt        -- "C:\"       -- absolute
 \\server\a\b\c.txt  -- "\\server\" -- UNC

 Unix:
 a/b/c.txt           -- ""          -- relative
 /a/b/c.txt          -- "/"         -- absolute
 ~/a/b/c.txt         -- "~/"        -- current user
 ~                   -- "~/"        -- current user (slash added)
 ~user/a/b/c.txt     -- "~user/"    -- named user
 ~user               -- "~user/"    -- named user (slash added)

getPrefixLength

int getPrefixLength()
Info:
Returns the length of the filename prefix, such as
Returns:
the length of the prefix, -1 if invalid or null

Example
Copy
C:/ or ~/.
 This method will handle a file in either Unix or Windows format.
 
 The prefix length includes the first slash in the full filename
 if applicable. Thus, it is possible that the length returned is greater
 than the length of the input string.
 
 Windows:
 a\b\c.txt           -- ""          -- relative
 \a\b\c.txt          -- "\"         -- current drive absolute
 C:a\b\c.txt         -- "C:"        -- drive relative
 C:\a\b\c.txt        -- "C:\"       -- absolute
 \\server\a\b\c.txt  -- "\\server\" -- UNC

 Unix:
 a/b/c.txt           -- ""          -- relative
 /a/b/c.txt          -- "/"         -- absolute
 ~/a/b/c.txt         -- "~/"        -- current user
 ~                   -- "~/"        -- current user (slash added)
 ~user/a/b/c.txt     -- "~user/"    -- named user
 ~user               -- "~user/"    -- named user (slash added)

indexOfExtension

int indexOfExtension(String filename)
Info:
Returns the index of the last extension separator character, which is a dot.
Parameters:
filename - 
Returns:
the index of the last separator character, or -1 if there is no such character

indexOfLastSeparator

int indexOfLastSeparator(String filename)
Info:
Returns the index of the last directory separator character.
Parameters:
filename - 
Returns:
the index of the last separator character, or -1 if there is no such character

isExtension

boolean isExtension(String extension)
Info:
Checks whether the extension of the filename is that specified.
Parameters:
extension - the extension to check for, null or empty checks for no extension
Returns:
true if the filename has the specified extension

isExtension

boolean isExtension(String[] extensions)
Info:
Checks whether the extension of the filename is one of those specified.
Parameters:
extensions - the extensions to check for, null checks for no extension
Returns:
true if the filename is one of the extensions

isExtension

boolean isExtension(Collection<String> extensions)
Info:
Checks whether the extension of the filename is one of those specified.
Parameters:
extensions - the extensions to check for, null checks for no extension
Returns:
true if the filename is one of the extensions

isSystemWindows

boolean isSystemWindows()
Info:
Determines if Windows file system is in use.
Returns:
true if the system is Windows

normalize

                        String normalize()
Info:
Normalizes a path, removing double and single dot path steps.
Returns:
the normalized filename, or null if invalid

Example
Copy
This method normalizes a path to a standard format.
 The input may contain separators in either Unix or Windows format.
 The output will contain separators in the format of the system.
 
 A trailing slash will be retained.
 A double slash will be merged to a single slash (but UNC names are handled).
 A single dot path segment will be removed.
 A double dot will cause that path segment and the one before to be removed.
 If the double dot has no parent path segment to work with, null
 is returned.
 
 The output will be the same on both Unix and Windows except
 for the separator character.
 
 /foo//               --   /foo/
 /foo/./              --   /foo/
 /foo/../bar          --   /bar
 /foo/../bar/         --   /bar/
 /foo/../bar/../baz   --   /baz
 //foo//./bar         --   /foo/bar
 /../                 --   null
 ../foo               --   null
 foo/bar/..           --   foo/
 foo/../../bar        --   null
 foo/../bar           --   bar
 //server/foo/../bar  --   //server/bar
 //server/../bar      --   null
 C:\foo\..\bar        --   C:\bar
 C:\..\bar            --   null
 ~/foo/../bar/        --   ~/bar/
 ~/../bar             --   null

normalize

                        String normalize(boolean unixSeparator)
Info:
Normalizes a path, removing double and single dot path steps.
Parameters:
unixSeparator - <code> true if a unix separator should be used or <code> false if a windows separator should be used.
Returns:
the normalized filename, or null if invalid

Example
Copy
This method normalizes a path to a standard format.
 The input may contain separators in either Unix or Windows format.
 The output will contain separators in the format specified.
 
 A trailing slash will be retained.
 A double slash will be merged to a single slash (but UNC names are handled).
 A single dot path segment will be removed.
 A double dot will cause that path segment and the one before to be removed.
 If the double dot has no parent path segment to work with, null
 is returned.
 
 The output will be the same on both Unix and Windows except
 for the separator character.
 
 /foo//               --   /foo/
 /foo/./              --   /foo/
 /foo/../bar          --   /bar
 /foo/../bar/         --   /bar/
 /foo/../bar/../baz   --   /baz
 //foo//./bar         --   /foo/bar
 /../                 --   null
 ../foo               --   null
 foo/bar/..           --   foo/
 foo/../../bar        --   null
 foo/../bar           --   bar
 //server/foo/../bar  --   //server/bar
 //server/../bar      --   null
 C:\foo\..\bar        --   C:\bar
 C:\..\bar            --   null
 ~/foo/../bar/        --   ~/bar/
 ~/../bar             --   null

normalizeNoEndSeparator

                        String normalizeNoEndSeparator()
Info:
Normalizes a path, removing double and single dot path steps, and removing any final directory separator.
Returns:
the normalized filename, or null if invalid

Example
Copy
This method normalizes a path to a standard format.
 The input may contain separators in either Unix or Windows format.
 The output will contain separators in the format of the system.
 
 A trailing slash will be removed.
 A double slash will be merged to a single slash (but UNC names are handled).
 A single dot path segment will be removed.
 A double dot will cause that path segment and the one before to be removed.
 If the double dot has no parent path segment to work with, null
 is returned.
 
 The output will be the same on both Unix and Windows except
 for the separator character.
 
 /foo//               --   /foo
 /foo/./              --   /foo
 /foo/../bar          --   /bar
 /foo/../bar/         --   /bar
 /foo/../bar/../baz   --   /baz
 //foo//./bar         --   /foo/bar
 /../                 --   null
 ../foo               --   null
 foo/bar/..           --   foo
 foo/../../bar        --   null
 foo/../bar           --   bar
 //server/foo/../bar  --   //server/bar
 //server/../bar      --   null
 C:\foo\..\bar        --   C:\bar
 C:\..\bar            --   null
 ~/foo/../bar/        --   ~/bar
 ~/../bar             --   null

normalizeNoEndSeparator

                        String normalizeNoEndSeparator(boolean unixSeparator)
Info:
Normalizes a path, removing double and single dot path steps, and removing any final directory separator.
Parameters:
unixSeparator - <code> true if a unix separator should be used or <code> false if a windows separtor should be used.
Returns:
the normalized filename, or null if invalid

Example
Copy
This method normalizes a path to a standard format.
 The input may contain separators in either Unix or Windows format.
 The output will contain separators in the format specified.
 
 A trailing slash will be removed.
 A double slash will be merged to a single slash (but UNC names are handled).
 A single dot path segment will be removed.
 A double dot will cause that path segment and the one before to be removed.
 If the double dot has no parent path segment to work with, null
 is returned.
 
 The output will be the same on both Unix and Windows including
 the separator character.
 
 /foo//               --   /foo
 /foo/./              --   /foo
 /foo/../bar          --   /bar
 /foo/../bar/         --   /bar
 /foo/../bar/../baz   --   /baz
 //foo//./bar         --   /foo/bar
 /../                 --   null
 ../foo               --   null
 foo/bar/..           --   foo
 foo/../../bar        --   null
 foo/../bar           --   bar
 //server/foo/../bar  --   //server/bar
 //server/../bar      --   null
 C:\foo\..\bar        --   C:\bar
 C:\..\bar            --   null
 ~/foo/../bar/        --   ~/bar
 ~/../bar             --   null

removeExtension

                        String removeExtension()
Info:
Removes the extension from a filename.
Returns:
the filename minus the extension

Example
Copy
This method returns the textual part of the filename before the last dot.
 There must be no directory separator after the dot.
 
 foo.txt    -- foo
 a\b\c.jpg  -- a\b\c
 a\b\c      -- a\b\c
 a.b\c      -- a.b\c

separatorsToSystem

                        String separatorsToSystem()
Info:
Converts all separators to the system separator.
Returns:
the updated path

separatorsToUnix

                        String separatorsToUnix()
Info:
Converts all separators to the Unix separator of forward slash.
Returns:
the updated path

separatorsToWindows

                        String separatorsToWindows()
Info:
Converts all separators to the Windows separator of backslash.
Returns:
the updated path

splitOnTokens

                        String[] splitOnTokens(String text)
Info:
Splits a string into a number of tokens. The text is split by '?' and '*'. Where multiple '*' occur consecutively they are collapsed into a single '*'.
Parameters:
text - the text to split
Returns:
the array of tokens, never null

wildcardMatch

boolean wildcardMatch(String wildcardMatcher)
Info:
Checks a filename to see if it matches the specified wildcard matcher, always testing case-sensitive.
Parameters:
wildcardMatcher - the wildcard string to match against
Returns:
true if the filename matches the wilcard string

Example
Copy
The wildcard matcher uses the characters '?' and '*' to represent a
 single or multiple (zero or more) wildcard characters.
 This is the same as often found on Dos/Unix command lines.
 The check is case-sensitive always.
 
 wildcardMatch("c.txt", "*.txt")      -- true
 wildcardMatch("c.txt", "*.jpg")      -- false
 wildcardMatch("a/b/c.txt", "a/b/*")  -- true
 wildcardMatch("c.txt", "*.???")      -- true
 wildcardMatch("c.txt", "*.????")     -- false

wildcardMatch

boolean wildcardMatch(String filename, String wildcardMatcher, IOCase caseSensitivity)
Info:
Checks a filename to see if it matches the specified wildcard matcher allowing control over case-sensitivity.
Parameters:
filename - the filename to match on
wildcardMatcher - the wildcard string to match against
caseSensitivity - what case sensitivity rule to use, null means case-sensitive
Returns:
true if the filename matches the wilcard string

wildcardMatchOnSystem

boolean wildcardMatchOnSystem(String wildcardMatcher)
Info:
Checks a filename to see if it matches the specified wildcard matcher using the case rules of the system.
Parameters:
wildcardMatcher - the wildcard string to match against
Returns:
true if the filename matches the wilcard string

Example
Copy
The wildcard matcher uses the characters '?' and '*' to represent a
 single or multiple (zero or more) wildcard characters.
 This is the same as often found on Dos/Unix command lines.
 The check is case-sensitive on Unix and case-insensitive on Windows.
 
 wildcardMatch("c.txt", "*.txt")      -- true
 wildcardMatch("c.txt", "*.jpg")      -- false
 wildcardMatch("a/b/c.txt", "a/b/*")  -- true
 wildcardMatch("c.txt", "*.???")      -- true
 wildcardMatch("c.txt", "*.????")     -- false

3 FileLogger

Class Ax.io.FileLogger


Allows to create a logger to a file to handle specific application log separated from javascript console.log var logger = new Ax.io.FileLogger("/tmp/debug.log"); logger.log("Hello");

Constructor Summary

MethodDescription
JSFileLogger(String name)Creates a new instance that will have the specified name as a pathname.
JSFileLogger(JSFile object)Creates a new instance that will have as pathname the one specified by the JSFile.

Method Summary

Modifier and TypeMethodDescription
void close()Closes the writer.
void debug(String msg)Writes the given message to the file.
void debug(Class clazz, String msg)Writes the given message to the file wih the format: "class: msg", where class is the name of the class clazz.
ProgressMonitorController getProgress(int goal, String taskName)
ProgressMonitorController getProgress(int arg0)
void log(String msg)Writes the given message to the file.
void warn(Class clazz, String msg)Writes the given message to the file wih the format: "WARN class: msg", where class is the name of the class clazz.

Method Detail

JSFileLogger

 JSFileLogger(String name)
Info:
Creates a new instance that will have the specified name as a pathname.
Parameters:
name - pathname of the file

JSFileLogger

 JSFileLogger(JSFile object)
Info:
Creates a new instance that will have as pathname the one specified by the JSFile.
Parameters:
object - 

close

void close()
Info:
Closes the writer.

debug

void debug(String msg)
Info:
Writes the given message to the file.
Parameters:
msg - text to write to the file

debug

void debug(Class clazz, String msg)
Info:
Writes the given message to the file wih the format: "class: msg", where class is the name of the class clazz.
Parameters:
clazz - class to get the name from
msg - message to write to he file

getProgress

                        ProgressMonitorController getProgress(int goal, String taskName)
Parameters:
goal - 
taskName - 
Returns:

getProgress

                        ProgressMonitorController getProgress(int arg0)
Parameters:
arg0 - 
Returns:

log

void log(String msg)
Info:
Writes the given message to the file.
Parameters:
msg - text to write to the file

warn

void warn(Class clazz, String msg)
Info:
Writes the given message to the file wih the format: "WARN class: msg", where class is the name of the class clazz.
Parameters:
clazz - class to get the name from
msg - message to write to he file

4 LineNumberReader

Class Ax.io.LineNumberReader


Constructor Summary

MethodDescription
JSLineNumberReader(Object src)
JSLineNumberReader(Object src, String charset)
JSLineNumberReader(Object src, Charset charSet)

Method Summary

Modifier and TypeMethodDescription
void forEach(Consumer arg0)
int getLineNumber()
Iterator iterator()
Spliterator spliterator()

Method Detail

JSLineNumberReader

 JSLineNumberReader(Object src)
Parameters:
src - 

JSLineNumberReader

 JSLineNumberReader(Object src, String charset)
Parameters:
src - 
charset - 

JSLineNumberReader

 JSLineNumberReader(Object src, Charset charSet)
Parameters:
src - 
charSet - 

forEach

void forEach(Consumer arg0)
Parameters:
arg0 - 

getLineNumber

int getLineNumber()
Returns:

iterator

                        Iterator iterator()
Returns:

spliterator

                        Spliterator spliterator()
Returns: