예제 #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;
 }