- java.lang.Object
-
- javax0.jamal.tools.FileTools
-
public class FileTools extends java.lang.Object
Utility class containing static methods handling files.
-
-
Constructor Summary
Constructors Constructor Description FileTools()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
absolute(java.lang.String reference, java.lang.String fileName)
Convert the file name to an absolute file name if it is relative to the directory containing the reference file.static Input
getInput(java.lang.String fileName)
Create a new input from a file.
-
-
-
Method Detail
-
getInput
public static Input getInput(java.lang.String fileName) throws BadSyntax
Create a new input from a file.- Parameters:
fileName
- the name of the file. This is used to open and read the file as well as reference file name in the input.- Returns:
- the input containing the contend of the file.
- Throws:
BadSyntaxAt
- if the file cannot be read.BadSyntax
-
absolute
public static java.lang.String absolute(java.lang.String reference, java.lang.String fileName)
Convert the file name to an absolute file name if it is relative to the directory containing the reference file. Note thatreference
is the name of a file and not a directory.If the name of the file starts with one of the characters:
/
\
~
or starts with an alpha character and a
:
(DOS drive letter, likeC:
then the file name is absolute and it is returned as it is.Otherwise the string in the parameter
reference
is used as it was a file name (the file does not need to exist) andfile
is treated as a relative file name and the absolute path is calculated.- Parameters:
reference
- the name of the reference filefileName
- the name of the file, absolute or relative- Returns:
- the absolute file name of the file
-
-