You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ctakes.apache.org by ja...@apache.org on 2013/07/19 22:53:08 UTC

svn commit: r1505011 - /ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/resource/FileLocator.java

Author: james-masanz
Date: Fri Jul 19 20:53:08 2013
New Revision: 1505011

URL: http://svn.apache.org/r1505011
Log:
CTAKES-218 Have FileLocator also try the second method to resolve the file path if the first returns null (in addition to if the first throws an exception)

Modified:
    ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/resource/FileLocator.java

Modified: ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/resource/FileLocator.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/resource/FileLocator.java?rev=1505011&r1=1505010&r2=1505011&view=diff
==============================================================================
--- ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/resource/FileLocator.java (original)
+++ ctakes/trunk/ctakes-core/src/main/java/org/apache/ctakes/core/resource/FileLocator.java Fri Jul 19 20:53:08 2013
@@ -38,11 +38,14 @@ public class FileLocator
         try
         {
         	//Get from classpath
-        	return FileLocator.class.getClassLoader().getResourceAsStream(location);
+        	InputStream is  = FileLocator.class.getClassLoader().getResourceAsStream(location);
+        	if (is==null) throw new RuntimeException("Unable to locate " + location + " on classpath.");
+        	return is;
         }
         catch (Exception e)
         {
-        	//Try to get from filestream
+        	//Try to get from filestream, locating relative to the current directory if 
+        	// location is a relative path
         	File f = new File(location);
         	FileInputStream fs = new FileInputStream(f);
         	return fs;