示例#1
0
 public static File getClassLoaderFile(String fileName) throws FileNotFoundException {
   try {
     return Utilities.getClassLoaderFile(fileName);
   } catch (FileNotFoundException e) {
     // ignore
   }
   return new File(Utilities.getClassLoaderRoot(), fileName);
 }
示例#2
0
 public static File retrieveFile(String directory, String fileName) {
   fileName = encodeTopicName(fileName);
   String fullName = directory + fileName;
   try {
     return Utilities.getClassLoaderFile(fullName);
   } catch (FileNotFoundException e) {
   }
   try {
     return new File(Utilities.getClassLoaderRoot(), fullName);
   } catch (FileNotFoundException e) {
   }
   return null;
 }
示例#3
0
 /**
  * Utility methods for retrieving property files from the class path, based on code from the
  * org.apache.log4j.helpers.Loader class.
  *
  * @param filename Given a filename return a File object for the file. The filename may be
  *     relative to the class path or the directory from which the JVM was initialized.
  */
 private static File getPropertyFile(String filename) {
   File file = null;
   try {
     file = Utilities.getClassLoaderRoot();
   } catch (Exception e) {
     logger.error("Error while searching for resource " + filename, e);
     return null;
   }
   try {
     file = new File(file, filename);
   } catch (Exception e) {
     logger.warn("Could not create filename for " + filename);
   }
   return file;
 }
示例#4
0
 /**
  * Utility methods for retrieving property files from the class path, based on code from the
  * org.apache.log4j.helpers.Loader class.
  *
  * @param filename Given a filename return a File object for the file. The filename may be
  *     relative to the class path or the directory from which the JVM was initialized.
  * @return Returns a file representing the filename, or <code>null</code> if the file cannot be
  *     found.
  */
 private static File retrievePropertyFile(String filename) {
   File file = null;
   try {
     file = Utilities.getClassLoaderFile(filename);
     return file; // NOPMD
   } catch (Exception e) {
     // NOPMD file might not exist
   }
   try {
     file = new File(Utilities.getClassLoaderRoot(), filename);
     return file; // NOPMD
   } catch (Exception e) {
     logger.severe("Error while searching for resource " + filename, e);
   }
   return null;
 }
示例#5
0
 private TreeSet retrieveTranslationCodes() throws Exception {
   TreeSet codes = new TreeSet();
   File propertyRoot = Utilities.getClassLoaderRoot();
   File[] files = propertyRoot.listFiles();
   File file;
   String filename;
   for (int i = 0; i < files.length; i++) {
     file = files[i];
     if (!file.isFile()) continue;
     filename = file.getName();
     if (!StringUtils.hasText(filename)) continue;
     if (!filename.startsWith("ApplicationResources_") || !filename.endsWith(".properties"))
       continue;
     String code =
         filename.substring(
             "ApplicationResources_".length(), filename.length() - ".properties".length());
     if (StringUtils.hasText(code)) codes.add(code);
   }
   return codes;
 }