/[classpath]/classpath/java/net/URLClassLoader.java
ViewVC logotype

Diff of /classpath/java/net/URLClassLoader.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.31 by mark, Sat Jul 2 20:32:39 2005 UTC revision 1.32 by archie172, Sat Jul 9 20:12:00 2005 UTC
# Line 536  public class URLClassLoader extends Secu Line 536  public class URLClassLoader extends Secu
536      Resource getResource(String name)      Resource getResource(String name)
537      {      {
538        File file = new File(dir, name);        File file = new File(dir, name);
539        if (file.exists())        if (file.exists() && !file.isDirectory())
540          return new FileResource(this, name, file);          return new FileResource(this, name, file);
541        return null;        return null;
542      }      }
# Line 554  public class URLClassLoader extends Secu Line 554  public class URLClassLoader extends Secu
554    
555      InputStream getInputStream() throws IOException      InputStream getInputStream() throws IOException
556      {      {
       // Delegate to the URL content handler mechanism to retrieve an  
       // HTML representation of the directory listing if a directory  
       if (file.isDirectory())  
         {  
           URL url = getURL();  
           return url.openStream();  
         }  
       // Otherwise simply return a FileInputStream  
557        return new FileInputStream(file);        return new FileInputStream(file);
558      }      }
559    
560      public int getLength()      public int getLength()
561      {      {
       // Delegate to the URL content handler mechanism to retrieve the  
       // length of the HTML representation of the directory listing if  
       // a directory, or -1 if an exception occurs opening the directory.  
       if (file.isDirectory())  
         {  
           URL url = getURL();  
           try  
             {  
               URLConnection connection = url.openConnection();  
               return connection.getContentLength();  
             }  
           catch (IOException e)  
             {  
               return -1;  
             }  
         }  
       // Otherwise simply return the file length  
562        return (int) file.length();        return (int) file.length();
563      }      }
564    

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.32

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26