/[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.12 by tromey, Wed Dec 11 02:13:27 2002 UTC revision 1.13 by mark, Mon Dec 23 01:59:42 2002 UTC
# Line 271  public class URLClassLoader extends Secu Line 271  public class URLClassLoader extends Secu
271      abstract InputStream getInputStream() throws IOException;      abstract InputStream getInputStream() throws IOException;
272    }    }
273    
274      /**
275       * Returns the given URL with a canonicalized file path name when it
276       * is has the file protocol. Otherwise (or when the file part of the
277       * URL couldn't be canonicalized) it returns the original String.
278       * It makes sure that if the original file part ended with a file
279       * separator that the new file part also ends with a separator.
280       */
281    static URL getCanonicalFileURL(URL url)    static URL getCanonicalFileURL(URL url)
282    {    {
283      if ("file".equals(url.getProtocol()))      if ("file".equals(url.getProtocol()))
284        {        {
285          try          try
286            {            {
287              File f = new File(url.getFile()).getCanonicalFile();              String f = url.getFile();
288              url = new URL("file", "", f.toString());              File file = new File(f).getCanonicalFile();
289                String cf = file.toString();
290                String sep = File.separator;
291                if (f.endsWith(sep) && !cf.endsWith(sep))
292                  {
293                    cf += "/";
294                  }
295                url = new URL("file", "", cf);
296            }            }
297          catch (IOException ignore)          catch (IOException ignore)
298            {            {

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

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