1 File

Class Ax.io.File


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

Constructor Summary

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

Method Summary

Modifier and Type
Method
Description
long 
append(byte[] data)
Appends a byte[] to file, creating the file if it doesn't exist.
void 
append(Ax.text.String text)
Appends a text as UTF-8, creating the file if doesn't exist.
void 
append(Ax.text.String text, Ax.text.String charsetName)
Appends the given text with the given charset.
void 
append(Ax.text.String text,Ax.text.String charsetName,boolean ignoreErrors)
Appends the given text with the specified encoding.
byte[] 
Return the file as byte[].
Ax.text.String 
Return the file as UTF-8 String.
Ax.text.String 
asString(Ax.text.String encoding)
Return the file as String.
boolean 
Checks whether user has execute permission on the file.
boolean 
Checks whether user has read permission on the file.
boolean 
Checks whether user has write permission on the file.
int 
compareTo(Ax.io.File o)
Compares lexicographically 2 pathnames.
Ax.io.File 
Creates a new temporary file (.
Ax.io.File 
createTempFile(Ax.text.String tempName)
Creates a new temporary file (.
Ax.io.File 
Allows creating a temp folder which will be automatically deleted on exit, inside the application temporary folder:
Ax.io.File 
createTempFolder(Ax.text.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.
Ax.text.String 
Returns the absolute form of this abstract pathname.
Ax.text.String 
Returns the absolute form of this abstract pathname.
Ax.text.String 
Returns the file content type according "https://www.
long 
Returns the creation time in milliseconds since the epoch (1970-01-01T00:00:00Z).
long 
Returns the number of unallocated bytes in the partition by this abstract path name.
long 
Returns the time of last access in milliseconds since the epoch (1970-01-01T00:00:00Z).
long 
Returns the time of last modification in milliseconds since the epoch (1970-01-01T00:00:00Z).
long 
Returns the count of lines from a file.
long 
getLineCount(Ax.text.String encoding)
Originally we use
Ax.text.String 
Returns the name of the file or directory (last name in the pathname).
Ax.text.String 
getNameTo(Ax.text.String separator)
Given a temp file like: /var/folders/h1/chsft9sj5pz64g45lmfbwdym0000gn/T/axional-863/JSFile/abc-13452678154332861398.
Ax.io.File 
Returns the parent file abstract pathname.
boolean 
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 
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.
lines()
Returns a Stream of lines from a file.
Returns a Stream of lines from a file.
List 
list()
Returns a list of strings naming the files and directories in the directory denoted by this abstract pathname.
List 
Returns a list of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
List 
Returns a list of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
List 
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[] 
Reads all the bytes from a file.
Ax.text.String 
Reads all content from a file into a string, decoding from bytes to characters using UTF8 charset.
Ax.text.String 
readString(Ax.text.String charsetName)
Reads all content from a file into a string, decoding from bytes to characters using UTF8 charset.
Ax.text.String 
readString(Ax.text.String charsetName, boolean ignoreErrors)
Reads all content from a file into a string, decoding from bytes to characters using UTF8 charset.
boolean 
renameTo(Ax.io.File file)
Renames the file denoted by this abstract pathname.
boolean 
renameTo(Ax.text.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.
toBlob()
Saves the file de noted by the pathname as a BLOB.
Returns a new FileInputStream of the file.
Returns a new FileOutputStream of the file.
Returns a new FileReader of the file.
toReader(Ax.text.String charsetName)
Returns a new FileReader of the file, using thespecified charset WARNING: Available since JDK 10
Ax.text.String 
Returns a String with the path of the file.
Returns a new FileWriter of the file.
Ax.io.File 
Notice that when we open a file with new File() if can be read, so it's content is not removed unless we truncate it.
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 
Writes the data into the file denoted by the pathname.
void 
write(Ax.text.String text)
Writes the text into the file denoted by the pathname, using UTF8 charset.
void 
write(Ax.text.String text, Ax.text.String charsetName)
Writes the text into the file denoted by the pathname, using the specified charset.
void 
write(Ax.text.String text,Ax.text.String charsetName,boolean ignoreErrors)
Writes the text into the file denoted by the pathname, using the specified charset.

Constructor Detail

Ax.io.File.JSFile

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

Ax.io.File.JSFile

Ax.io.File.JSFile(
	file 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")

Ax.io.File.JSFile

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

Ax.io.File.JSFile

Ax.io.File.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

Ax.io.File.JSFile

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

Method Detail

Ax.io.File.append

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

Ax.io.File.append

null Ax.io.File.append(
	string text
)
Info:
Appends a text as UTF-8, creating the file if doesn't exist.
Parameters:
text - text to append
Returns:
null

Ax.io.File.append

null Ax.io.File.append(
	string text,
	string charsetName
)
Info:
Appends the given text with the given charset. Creates the file if doesn't exist.
Parameters:
text - text to append
charsetName - character encoding
Returns:
null

Ax.io.File.append

null Ax.io.File.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
Returns:
null

Ax.io.File.asBytes

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

Ax.io.File.asString

string Ax.io.File.asString()
Info:
Return the file as UTF-8 String.
Returns:
string

Ax.io.File.asString

string Ax.io.File.asString(
	string encoding
)
Info:
Return the file as String.
Parameters:
encoding - 
Returns:
string

Ax.io.File.canExecute

boolean Ax.io.File.canExecute()
Info:
Checks whether user has execute permission on the file.
Returns:
boolean

Ax.io.File.canRead

boolean Ax.io.File.canRead()
Info:
Checks whether user has read permission on the file.
Returns:
boolean

Ax.io.File.canWrite

boolean Ax.io.File.canWrite()
Info:
Checks whether user has write permission on the file.
Returns:
boolean

Ax.io.File.compareTo

smallint Ax.io.File.compareTo(
	file 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:
smallint

Ax.io.File.createTempFile

file Ax.io.File.createTempFile()
Info:
Creates a new temporary file (.tmp).
Returns:
file

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

Ax.io.File.createTempFile

file Ax.io.File.createTempFile(
	string tempName
)
Info:
Creates a new temporary file (.tmp) with the specified name.
Parameters:
tempName - the name of the temporary file
Returns:
file

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

Ax.io.File.createTempFolder

file Ax.io.File.createTempFolder()
Info:
Allows creating a temp folder which will be automatically deleted on exit, inside the application temporary folder:
Returns:
file

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

Ax.io.File.createTempFolder

file Ax.io.File.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:
file

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

Ax.io.File.delete

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

Ax.io.File.exists

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

Ax.io.File.getAbsolutePath

string Ax.io.File.getAbsolutePath()
Info:
Returns the absolute form of this abstract pathname.
Returns:
string

Ax.io.File.getCanonicalPath

string Ax.io.File.getCanonicalPath()
Info:
Returns the absolute form of this abstract pathname.
Returns:
string

Ax.io.File.getContentType

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

Ax.io.File.getCreationTime

long Ax.io.File.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:
long

Ax.io.File.getFreeSpace

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

Ax.io.File.getLastAccessTime

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

Ax.io.File.getLastModified

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

Ax.io.File.getLineCount

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

Ax.io.File.getLineCount

long Ax.io.File.getLineCount(
	string encoding
)
Info:
Originally we use
Parameters:
encoding - 
Returns:
long

Example
Copy
return Files.lines(getObject().toPath()).count();
Example
Copy
java.io.UncheckedIOException: java.nio.charset.MalformedInputException: Input length = 1

Ax.io.File.getName

string Ax.io.File.getName()
Info:
Returns the name of the file or directory (last name in the pathname).
Returns:
string

Ax.io.File.getNameTo

string Ax.io.File.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:
string

Ax.io.File.getParentFile

file Ax.io.File.getParentFile()
Info:
Returns the parent file abstract pathname.
Returns:
file

Ax.io.File.isDirectory

boolean Ax.io.File.isDirectory()
Info:
Checks whether the file denoted by this abstract pathname is a directory file.
Returns:
boolean

Ax.io.File.isFile

boolean Ax.io.File.isFile()
Info:
Checks whether the file denoted by this abstract pathname is a normal file.
Returns:
boolean

Ax.io.File.lastModified

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

Ax.io.File.length

long Ax.io.File.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:
long

Ax.io.File.lines

object Ax.io.File.lines()
Info:
Returns a Stream of lines from a file. Stream inherits an iterator() method to produce an Iterator. But Nashorn/Graal need an Iterable rather than an Iterator.
Returns:
object

Ax.io.File.linesStream

object Ax.io.File.linesStream()
Info:
Returns a Stream of lines from a file.
Returns:
object

Ax.io.File.list

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

Ax.io.File.list

array Ax.io.File.list(
	object filter
)
Info:
Returns a list of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
Parameters:
filter - filter Function
Returns:
array

Ax.io.File.listFiles

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

Ax.io.File.listFiles

array Ax.io.File.listFiles(
	object 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:
array

Ax.io.File.mkdir

boolean Ax.io.File.mkdir()
Info:
Creates yhe directory defined by the pathname.
Returns:
boolean

Ax.io.File.mkdirs

boolean Ax.io.File.mkdirs()
Info:
Creates he directory defined by the pathname, and all the necessary paretn directories.
Returns:
boolean

Ax.io.File.readBytes

byte[] Ax.io.File.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:
byte[]

Ax.io.File.readString

string Ax.io.File.readString()
Info:
Reads all content from a file into a string, decoding from bytes to characters using UTF8 charset.
Returns:
string

Ax.io.File.readString

string Ax.io.File.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

Ax.io.File.readString

string Ax.io.File.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

Ax.io.File.renameTo

boolean Ax.io.File.renameTo(
	file file
)
Info:
Renames the file denoted by this abstract pathname.
Parameters:
file - new name
Returns:
boolean

Ax.io.File.renameTo

boolean Ax.io.File.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:
boolean

Ax.io.File.split

array Ax.io.File.split(
	smallint 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:
array

Ax.io.File.toBlob

object Ax.io.File.toBlob()
Info:
Saves the file de noted by the pathname as a BLOB.
Returns:
object

Ax.io.File.toInputStream

object Ax.io.File.toInputStream()
Info:
Returns a new FileInputStream of the file.
Returns:
object

Ax.io.File.toOutputStream

object Ax.io.File.toOutputStream()
Info:
Returns a new FileOutputStream of the file.
Returns:
object

Ax.io.File.toReader

object Ax.io.File.toReader()
Info:
Returns a new FileReader of the file.
Returns:
object

Ax.io.File.toReader

object Ax.io.File.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:
object

Ax.io.File.toString

string Ax.io.File.toString()
Info:
Returns a String with the path of the file.
Returns:
string

Ax.io.File.toWriter

object Ax.io.File.toWriter()
Info:
Returns a new FileWriter of the file.
Returns:
object

Ax.io.File.truncate

file Ax.io.File.truncate()
Info:
Notice that when we open a file with new File() if can be read, so it's content is not removed unless we truncate it.
Returns:
file

Ax.io.File.write

long Ax.io.File.write(
	object data
)
Info:
Writes the data into the file denoted by the pathname.
Parameters:
data - data to write
Returns:
long

Ax.io.File.write

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

Ax.io.File.write

long Ax.io.File.write(
	object data
)
Info:
Writes the data into the file denoted by the pathname.
Parameters:
data - data to write
Returns:
long

Ax.io.File.write

null Ax.io.File.write(
	string text
)
Info:
Writes the text into the file denoted by the pathname, using UTF8 charset.
Parameters:
text - text to write
Returns:
null

Ax.io.File.write

null Ax.io.File.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
Returns:
null

Ax.io.File.write

null Ax.io.File.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
Returns:
null

2 FileName

Class Ax.io.FileName


The FileName class returns information about a file path

Constructor Summary

Method
Description
JSFileName(Ax.io.File file)
JSFileName(Ax.text.String name)

Method Summary

Modifier and Type
Method
Description
Ax.text.String 
Gets the base name, minus the full path and extension, from a full filename.
Ax.text.String 
Gets the extension of a filename.
Ax.text.String 
Gets the full path from a full filename, which is the prefix + path.
Ax.text.String 
Gets the full path from a full filename, which is the prefix + path, and also excluding the final directory separator.
Ax.text.String 
Gets the name minus the path from a full filename.
Ax.text.String 
Gets the path from a full filename, which excludes the prefix.
Ax.text.String 
Gets the path from a full filename, which excludes the prefix, and also excluding the final directory separator.
Ax.text.String 
Gets the prefix from a full filename, such as C:/ or ~/.
int 
Returns the length of the filename prefix, such as C:/ or ~/.
int 
indexOfExtension(Ax.text.String filename)
Returns the index of the last extension separator character, which is a dot.
int 
indexOfLastSeparator(Ax.text.String filename)
Returns the index of the last directory separator character.
boolean 
isExtension(Ax.text.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 
Determines if Windows file system is in use.
Ax.text.String 
Normalizes a path, removing double and single dot path steps.
Ax.text.String 
normalize(boolean unixSeparator)
Normalizes a path, removing double and single dot path steps.
Ax.text.String 
Normalizes a path, removing double and single dot path steps, and removing any final directory separator.
Ax.text.String 
normalizeNoEndSeparator(boolean unixSeparator)
Normalizes a path, removing double and single dot path steps, and removing any final directory separator.
Ax.text.String 
Removes the extension from a filename.
Ax.text.String 
Converts all separators to the system separator.
Ax.text.String 
Converts all separators to the Unix separator of forward slash.
Ax.text.String 
Converts all separators to the Windows separator of backslash.
splitOnTokens(Ax.text.String text)
Splits a string into a number of tokens.
Ax.text.String 
boolean 
wildcardMatch(Ax.text.String wildcardMatcher)
Checks a filename to see if it matches the specified wildcard matcher, always testing case-sensitive.
boolean 
wildcardMatch(Ax.text.String filename, Ax.text.String wildcardMatcher, IOCase caseSensitivity)
Checks a filename to see if it matches the specified wildcard matcher allowing control over case-sensitivity.
boolean 
wildcardMatchOnSystem(Ax.text.String wildcardMatcher)
Checks a filename to see if it matches the specified wildcard matcher using the case rules of the system.

Constructor Detail

Ax.io.FileName.JSFileName

Ax.io.FileName.JSFileName(
	file file
						)
Parameters:
file - 

Ax.io.FileName.JSFileName

Ax.io.FileName.JSFileName(
	string name
						)
Parameters:
name - 

Method Detail

Ax.io.FileName.getBaseName

string Ax.io.FileName.getBaseName()
Info:
Gets the base name, minus the full path and extension, from a full filename.
Returns:
string

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/    -- ""

Ax.io.FileName.getExtension

string Ax.io.FileName.getExtension()
Info:
Gets the extension of a filename.
Returns:
string

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        -- ""

Ax.io.FileName.getFullPath

string Ax.io.FileName.getFullPath()
Info:
Gets the full path from a full filename, which is the prefix + path.
Returns:
string

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/

Ax.io.FileName.getFullPathNoEndSeparator

string Ax.io.FileName.getFullPathNoEndSeparator()
Info:
Gets the full path from a full filename, which is the prefix + path, and also excluding the final directory separator.
Returns:
string

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

Ax.io.FileName.getName

string Ax.io.FileName.getName()
Info:
Gets the name minus the path from a full filename.
Returns:
string

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/    -- ""

Ax.io.FileName.getPath

string Ax.io.FileName.getPath()
Info:
Gets the path from a full filename, which excludes the prefix.
Returns:
string

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/

Ax.io.FileName.getPathNoEndSeparator

string Ax.io.FileName.getPathNoEndSeparator()
Info:
Gets the path from a full filename, which excludes the prefix, and also excluding the final directory separator.
Returns:
string

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

Ax.io.FileName.getPrefix

string Ax.io.FileName.getPrefix()
Info:
Gets the prefix from a full filename, such as C:/ or ~/.
Returns:
string

Example
Copy
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)

Ax.io.FileName.getPrefixLength

smallint Ax.io.FileName.getPrefixLength()
Info:
Returns the length of the filename prefix, such as C:/ or ~/.
Returns:
smallint

Example
Copy
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)

Ax.io.FileName.indexOfExtension

smallint Ax.io.FileName.indexOfExtension(
	string filename
)
Info:
Returns the index of the last extension separator character, which is a dot.
Parameters:
filename - the filename to find the last path separator in, null returns -1
Returns:
smallint

Ax.io.FileName.indexOfLastSeparator

smallint Ax.io.FileName.indexOfLastSeparator(
	string filename
)
Info:
Returns the index of the last directory separator character.
Parameters:
filename - the filename to find the last path separator in, null returns -1
Returns:
smallint

Ax.io.FileName.isExtension

boolean Ax.io.FileName.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:
boolean

Ax.io.FileName.isExtension

boolean Ax.io.FileName.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:
boolean

Ax.io.FileName.isExtension

boolean Ax.io.FileName.isExtension(
	object 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:
boolean

Ax.io.FileName.isSystemWindows

boolean Ax.io.FileName.isSystemWindows()
Info:
Determines if Windows file system is in use.
Returns:
boolean

Ax.io.FileName.normalize

string Ax.io.FileName.normalize()
Info:
Normalizes a path, removing double and single dot path steps.
Returns:
string

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

Ax.io.FileName.normalize

string Ax.io.FileName.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:
string

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

Ax.io.FileName.normalizeNoEndSeparator

string Ax.io.FileName.normalizeNoEndSeparator()
Info:
Normalizes a path, removing double and single dot path steps, and removing any final directory separator.
Returns:
string

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

Ax.io.FileName.normalizeNoEndSeparator

string Ax.io.FileName.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:
string

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

Ax.io.FileName.removeExtension

string Ax.io.FileName.removeExtension()
Info:
Removes the extension from a filename.
Returns:
string

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

Ax.io.FileName.separatorsToSystem

string Ax.io.FileName.separatorsToSystem()
Info:
Converts all separators to the system separator.
Returns:
string

Ax.io.FileName.separatorsToUnix

string Ax.io.FileName.separatorsToUnix()
Info:
Converts all separators to the Unix separator of forward slash.
Returns:
string

Ax.io.FileName.separatorsToWindows

string Ax.io.FileName.separatorsToWindows()
Info:
Converts all separators to the Windows separator of backslash.
Returns:
string

Ax.io.FileName.splitOnTokens

string[] Ax.io.FileName.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:
string[]

Ax.io.FileName.toString

string Ax.io.FileName.toString()
Returns:
string

Ax.io.FileName.wildcardMatch

boolean Ax.io.FileName.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:
boolean

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

Ax.io.FileName.wildcardMatch

boolean Ax.io.FileName.wildcardMatch(
	string filename,
	string wildcardMatcher,
	object 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:
boolean

Ax.io.FileName.wildcardMatchOnSystem

boolean Ax.io.FileName.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:
boolean

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

Method
Description
JSFileLogger(Ax.text.String name)
Creates a new instance that will have the specified name as a pathname.
JSFileLogger(Ax.io.File object)
Creates a new instance that will have as pathname the one specified by the JSFile.

Method Summary

Modifier and Type
Method
Description
void 
close()
Closes the writer.
void 
debug(Ax.text.String msg)
Writes the given message to the file.
void 
debug(Class clazz, Ax.text.String msg)
Writes the given message to the file wih the format: "class: msg", where class is the name of the class clazz.
getProgress(int goal,Ax.text.String taskName)
Returns a progress monitor that will log the progress onto the file (instead of console).
getProgress(int arg0)
void 
log(Ax.text.String msg)
Writes the given message to the file.
void 
warn(Class clazz, Ax.text.String msg)
Writes the given message to the file wih the format: "WARN class: msg", where class is the name of the class clazz.

Constructor Detail

Ax.io.FileLogger.JSFileLogger

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

Ax.io.FileLogger.JSFileLogger

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

Method Detail

Ax.io.FileLogger.close

null Ax.io.FileLogger.close()
Info:
Closes the writer.
Returns:
null

Ax.io.FileLogger.debug

null Ax.io.FileLogger.debug(
	string msg
)
Info:
Writes the given message to the file.
Parameters:
msg - text to write to the file
Returns:
null

Ax.io.FileLogger.debug

null Ax.io.FileLogger.debug(
	object 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
Returns:
null

Ax.io.FileLogger.getProgress

object Ax.io.FileLogger.getProgress(
	smallint goal,
	string taskName
)
Info:
Returns a progress monitor that will log the progress onto the file (instead of console).
Parameters:
goal - number of steps
taskName - name of the task
Returns:
object

Ax.io.FileLogger.getProgress

object Ax.io.FileLogger.getProgress(
	smallint arg0
)
Parameters:
arg0 - 
Returns:
object

Ax.io.FileLogger.log

null Ax.io.FileLogger.log(
	string msg
)
Info:
Writes the given message to the file.
Parameters:
msg - text to write to the file
Returns:
null

Ax.io.FileLogger.warn

null Ax.io.FileLogger.warn(
	object 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
Returns:
null

4 LineNumberReader

Class Ax.io.LineNumberReader


LineNumberReader is a buffered character-input stream that keeps track of line numbers. You can use LineNumberReader to read line by line any InputStream convertible object. By default, UTF-8 encoding will be used to construct the reader but you can give and optional argument with charset name to change it.

Constructor Summary

Method
Description
Creates new insance with source file.
JSLineNumberReader(Object src, Ax.text.String charset)
Creates a new reader of source file and with the specified charset.
Creates a new reader of source file and with the specified charset.

Method Summary

Modifier and Type
Method
Description
void 
forEach(Consumer arg0)
int 
Returns the current line number.
Returns an iterator over the file.

Constructor Detail

Ax.io.LineNumberReader.JSLineNumberReader

Ax.io.LineNumberReader.JSLineNumberReader(
	object src
						)
Info:
Creates new insance with source file.
Parameters:
src - source fle

Ax.io.LineNumberReader.JSLineNumberReader

Ax.io.LineNumberReader.JSLineNumberReader(
	object src,
	string charset
						)
Info:
Creates a new reader of source file and with the specified charset.
Parameters:
src - source file
charset - charset to use

Example
Copy
var src  = new Ax.io.File("/etc/hosts");
 var lnr = new Ax.io.LineNumberReader(src, "ISO-8859-1");

Ax.io.LineNumberReader.JSLineNumberReader

Ax.io.LineNumberReader.JSLineNumberReader(
	object src,
	object charSet
						)
Info:
Creates a new reader of source file and with the specified charset.
Parameters:
src - source file
charSet - charset to use

Method Detail

Ax.io.LineNumberReader.forEach

null Ax.io.LineNumberReader.forEach(
	object arg0
)
Parameters:
arg0 - 
Returns:
null

Ax.io.LineNumberReader.getLineNumber

smallint Ax.io.LineNumberReader.getLineNumber()
Info:
Returns the current line number.
Returns:
smallint

Ax.io.LineNumberReader.iterator

object Ax.io.LineNumberReader.iterator()
Info:
Returns an iterator over the file.
Returns:
object

Ax.io.LineNumberReader.spliterator

object Ax.io.LineNumberReader.spliterator()
Returns:
object