Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.infinispan.commons.util;
  
  import java.io.File;
  import java.net.URI;
 import java.net.URL;
 
 
 public abstract class AbstractFileLookup implements FileLookup {
 
    private static final BasicLogger log = BasicLogFactory.getLog(FileLookup.class);
 
    public AbstractFileLookup() {
       super();
    }

   
Looks up the file, see : FileLookupFactory.DefaultFileLookup.

Parameters:
filename might be the name of the file (too look it up in the class path) or an url to a file.
Returns:
an input stream to the file or null if nothing found through all lookup steps.
 
    @Override
    public InputStream lookupFile(String filenameClassLoader cl) {
       InputStream is = filename == null || filename.length() == 0 ? null : getAsInputStreamFromClassLoader(filenamecl);
       if (is == null) {
          if (.isDebugEnabled())
             .debugf("Unable to find file %s in classpath; searching for this file on the filesystem instead."filename);
          try {
             is = new FileInputStream(filename);
          }
          catch (FileNotFoundException e) {
             return null;
          }
       }
       return is;
    }
 
    protected abstract InputStream getAsInputStreamFromClassLoader(String filenameClassLoader cl);

   
Looks up the file, see : FileLookupFactory.DefaultFileLookup.

Parameters:
filename might be the name of the file (too look it up in the class path) or an url to a file.
Returns:
an input stream to the file or null if nothing found through all lookup steps.
Throws:
java.io.FileNotFoundException if file cannot be found
 
    @Override
    public InputStream lookupFileStrict(String filenameClassLoader clthrows FileNotFoundException {
       InputStream is = filename == null || filename.length() == 0 ? null : getAsInputStreamFromClassLoader(filenamecl);
       if (is == null) {
          if (.isDebugEnabled())
             .debugf("Unable to find file %s in classpath; searching for this file on the filesystem instead."filename);
          return new FileInputStream(filename);
       }
       return is;
    }
 
    @Override
    public InputStream lookupFileStrict(URI uriClassLoader clthrows FileNotFoundException {
       return new FileInputStream(new File(uri));
    }
 
    @Override
    public URL lookupFileLocation(String filenameClassLoader cl) {
       URL u = getAsURLFromClassLoader(filenamecl);
    
       if (u == null) {
          File f = new File(filename);
          if (f.exists()) try {
             u = f.toURI().toURL();
          }
          catch (MalformedURLException e) {
             // what do we do here?
          }
       }
       return u;
    }
 
    protected abstract URL getAsURLFromClassLoader(String filenameClassLoader cl);
 
    @Override
    public Collection<URLlookupFileLocations(String filenameClassLoader clthrows IOException {
       Collection<URLu = getAsURLsFromClassLoader(filenamecl);
    
          File f = new File(filename);
          if (f.exists()) try {
             u.add(f.toURI().toURL());
          }
          catch (MalformedURLException e) {
             // what do we do here?
         }
      return u;
   }
   protected abstract Collection<URLgetAsURLsFromClassLoader(String filenameClassLoader clthrows IOException;
New to GrepCode? Check out our FAQ X