ui/src/main/java/ucar/nc2/ui/util/Resource.java
public static InputStream getFileResource( String resourcePath) {

    InputStream is = cl.getResourceAsStream(resourcePath);
    if (is != null) {
      if (debug) System.out.println("Resource.getResourceAsStream ok on "+resourcePath);
      return is;
    } else if (debug)
      System.out.println("Resource.getResourceAsStream failed on ("+resourcePath+")");

    try {
      is =  new FileInputStream(resourcePath);
      if (debug) System.out.println("Resource.FileInputStream ok on "+resourcePath);
    } catch (FileNotFoundException e) {
      if (debug)  System.out.println("  FileNotFoundException: Resource.getFile failed on "+resourcePath);
    } catch (java.security.AccessControlException e) {
      if (debug)  System.out.println("  AccessControlException: Resource.getFile failed on "+resourcePath);
    }

    return is;
  }
public static InputStream getFileResource( String resourcePath) {

    InputStream is = cl.getResourceAsStream(resourcePath);
    if (is != null) {
      if (debug) System.out.println("Resource.getResourceAsStream ok on "+resourcePath);
      return is;
    } else if (debug)
      System.out.println("Resource.getResourceAsStream failed on ("+resourcePath+")");

    try {
      is =  new FileInputStream(resourcePath);
      if (debug) System.out.println("Resource.FileInputStream ok on "+resourcePath);
    } catch (FileNotFoundException e) {
      if (debug)  System.out.println("  FileNotFoundException: Resource.getFile failed on "+resourcePath);
    } catch (java.security.AccessControlException e) {
      if (debug)  System.out.println("  AccessControlException: Resource.getFile failed on "+resourcePath);
    }

    return is;
  }
public static InputStream getFileResource ( String resourcePath ) { InputStream is = cl . getResourceAsStream ( resourcePath ) ; if ( is != null ) { if ( debug ) System . out . println ( "Resource.getResourceAsStream ok on " + resourcePath ) ; return is ; } else if ( debug ) System . out . println ( "Resource.getResourceAsStream failed on (" + resourcePath + ")" ) ; try { is = new FileInputStream ( resourcePath ) ; if ( debug ) System . out . println ( "Resource.FileInputStream ok on " + resourcePath ) ; } catch ( FileNotFoundException e ) { if ( debug ) System . out . println ( "  FileNotFoundException: Resource.getFile failed on " + resourcePath ) ; } catch ( java . security . AccessControlException e ) { if ( debug ) System . out . println ( "  AccessControlException: Resource.getFile failed on " + resourcePath ) ; } return is ; }
Open a resource as a Stream. First try ClassLoader.getResourceAsStream().
If that fails, try a plain old FileInputStream().
@param resourcePath name of file path (use forward slashes!)
@return InputStream or null on failure
Open a resource as a Stream . First try ClassLoader . getResourceAsStream () . If that fails try a plain old FileInputStream () .