KSLFile Util
Provides some basic file utilities. Additional utilities can be found in Google Guava and Apache Commons IO. However, this basic IO provides basic needs without external libraries and is integrated withe KSL functionality.
Properties
Returns the path to the directory that the program was launched from on the OS. This call may throw a SecurityException if the system information is not accessible. Uses System property "user.dir"
Returns the directory that the program was launched from on the OS as a string. This call may throw a SecurityException if the system information is not accessible. Uses System property "user.dir"
System.out as a PrintWriter
Functions
Opens a file dialog to select a file to open. The dialog will open in the directory that the program was launched from.
Makes a String that has the form name.csv
Will throw an IOException if something goes wrong in the creation.
Creates a file in the directory that the program was launched from. Parent directories are created if they do not exist.
Creates a file within a specific parent directory. Parent directories are created if they do not exist.
Makes a String that has the form 'name.ext' If an extension already exists it is replaced.
Creates a file with a guaranteed extension in the specified parent directory. If the file name is null, a temporary name is generated.
Makes a LogPrintWriter from the given File. IOExceptions are caught and logged. If the file exists it will be written over.
Makes a PrintWriter from the given path, any IOExceptions are caught and logged.
Creates a file in the standard KSL output directory. Parent directories are created if they do not exist.
Makes a PrintWriter from the given File. IOExceptions are caught and logged. If the file exists it is written over.
Makes a PrintWriter from the given path, any IOExceptions are caught and logged. The path must be to a file, not a directory. If the directories that are on the path do not exist, they are created. If the referenced file exists it is written over.
Makes the file in the directory that the program launched within
Creates a subdirectory within the supplied main directory.
Creates a temporary HTML file in the specified directory with the given file name. The file will have a .html extension. If the directory does not exist, it will be created.
Makes a String that has the form name.txt
Recursively deletes
Deletes the directory represented by the path and all of its contents. If the path is not a directory, it is deleted as a file.
This method will check for the dot '.' occurrence in the given filename. If it exists, then it will find the last position of the dot '.' and return the characters after that, the characters after the last dot '.' known as the file extension. Special Cases:
This method will check for the dot '.' occurrence in the given filename. If it exists, then it will find the last position of the dot '.' and return the characters after that, the characters after the last dot '.' known as the file extension. Special Cases:
Opens the file in the browser. The file must be an HTML file and the system must have a default browser configured. If the file is not an HTML file or if there is no default browser, an IOException may be thrown.
Opens the HTML file in the browser. The file is created in the specified directory with the given file name. The file will have a .html extension. If the directory does not exist, it will be created.
Assumes that the file holds doubles with each value on a different line 1.0 4.0 2.0 etc
Allows writing directly to a known PrintWriter. Facilitates writing to the file before or after the array is written
Allows writing directly to a known PrintWriter. Facilitates writing to the file before or after the list is written
Writes the data in the array to rows in the file, each element in a row is separated by a comma
Writes the data in the array to rows in the file, each row with one data point