Commits

musachy  committed f7719d9

Add a parameter to FIleManager, so opening the inputstream is optional.

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@1899e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits da19800

Comments (0)

Files changed (1)

File src/java/com/opensymphony/xwork2/util/FileManager.java

         return loadFile(fileUrl);
     }
 
-    /**
+     /**
      * Loads opens the named file and returns the InputStream
      *
      * @param fileUrl - the URL of the file to open
      * @throws IllegalArgumentException if there is no file with the given file name
      */
     public static InputStream loadFile(URL fileUrl) {
+         return loadFile(fileUrl, true);
+     }
+
+    /**
+     * Loads opens the named file and returns the InputStream
+     *
+     * @param fileUrl - the URL of the file to open
+     * @param openStream - if true, open an InputStream to the file and return it
+     * @return an InputStream of the file contents or null
+     * @throws IllegalArgumentException if there is no file with the given file name
+     */
+    public static InputStream loadFile(URL fileUrl, boolean openStream) {
         if (fileUrl == null) {
             return null;
         }
 
         String fileName = fileUrl.toString();
-        InputStream is;
+        InputStream is = null;
 
-        try {
-            is = fileUrl.openStream();
+        if (openStream) {
+            try {
+                is = fileUrl.openStream();
 
-            if (is == null) {
+                if (is == null) {
+                    throw new IllegalArgumentException("No file '" + fileName + "' found as a resource");
+                }
+            } catch (IOException e) {
                 throw new IllegalArgumentException("No file '" + fileName + "' found as a resource");
             }
-        } catch (IOException e) {
-            throw new IllegalArgumentException("No file '" + fileName + "' found as a resource");
         }
 
         if (isReloadingConfigs()) {