FileExists() - I18N Method for Testing if a system file exists.
Java has a File.exists() method that returns true if the operating system can find a file. This is not good enough.
Windows will say a file exists even if the upper/lower case of the request is wrong. When this same file is looked for in a *nix machine or in a JAR the request will fail.
JGuiGen has a method in the model class that checks for files. It looks in three different ways.
You will see the following is seveal places.
This is used to gracefully abort classes if the ResourceBundle request would fail. Java crashes if the request has the wrong case. The FileExist() method will warn you that the file exists, but the case is wrong and then gracefully exit.
Here are the parameters.
@param path - this is the path where the file should be found.
| If it is ".", the system will use the directory where the application was started.
| If the path contains the file name, the file name will be stripped off. (Url'.toString() will have the file name on the end.)
@param - the file name we are looking for. Make sure the upper/lower case is what you want it to be.
@param - Is it an error if the file is missing? True/False. This is usually true. It can be false if you are looking for things like icons in an I18N situtation. If the icon file exists in the images_Loc_Country folder, it should be in the right upper/lower case. If it is missing, then it is okay to use the standard image.
@param - localeDirecotry. - JGuiGen looks for resource files for locale's other than the base (in my case English) locale) in a directory under the home directory where the application starts. The history.htm file is a case in point. If your locale is Spanish (es), the system expects your history.htm file to be written in Spanish and to reside in the History/es folder. If your locale is Spanish-Mexican, the system expects your history.htm file to be in a History/is_Mx folder. If there is not a file in the es_MX folder or the es folder, the method will deliver a waring message that the file is missing. Java will resort to using the English version of the properties file, but I at least want to know that the properties file is not there so I can deal with the issue before the users run into it.
|If the localeDirectory is "properties" the system knows that it is looking ar I18N properties files. It will look for the filename+"_es.properties" for a Spanish locale and filename_ex_MX.properties for a Spanish-Mexican locale. It will dliver a warning message if neither of these files exists.
|1). This method checks to see if the case of a file is correct and delivers a warning message if the case is wrong, even though Windows allows the use of the file in its current case.
| 2) The method can check for missing properties files.
| 3) The method can check for missing system resources that use the JGuiGen subfolder rules for handling different Locale resources. (These same rules are used for text files and images files.)