/[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.28 by mark, Tue Feb 15 19:55:56 2005 UTC revision 1.29 by dog, Wed Mar 2 08:46:34 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() && ! file.isDirectory())        if (file.exists())
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      {      {
557          // Delegate to the URL content handler mechanism to retrieve an
558          // HTML representation of the directory listing if a directory
559          if (file.isDirectory())
560            {
561              URL url = getURL();
562              return url.openStream();
563            }
564          // Otherwise simply return a FileInputStream
565        return new FileInputStream(file);        return new FileInputStream(file);
566      }      }
567    
568      public int getLength()      public int getLength()
569      {      {
570          // Delegate to the URL content handler mechanism to retrieve the
571          // length of the HTML representation of the directory listing if
572          // a directory, or -1 if an exception occurs opening the directory.
573          if (file.isDirectory())
574            {
575              URL url = getURL();
576              try
577                {
578                  URLConnection connection = url.openConnection();
579                  return connection.getContentLength();
580                }
581              catch (IOException e)
582                {
583                  return -1;
584                }
585            }
586          // Otherwise simply return the file length
587        return (int) file.length();        return (int) file.length();
588      }      }
589    

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29

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