Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4636168

File construction using URL and Channel access

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.4.0, 1.4.1
    • core-libs
    • generic, x86
    • generic, windows_98

      Name: nt126004 Date: 02/11/2002


      FULL PRODUCT VERSION :
      java version "1.4.0-rc"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b91)
      Java Hotspot(TM) Client VM (build 1.4.0-rc-b91, mixed mode)


      FULL OPERATING SYSTEM VERSION :

      Windows 98 [Version 4.10.2222]



      A DESCRIPTION OF THE PROBLEM :

      I noticed that File now support some new methods for
      transformation into URL and URI, however File itself does
      not support the opposite direction, so I would like to
      propose that you add a constructor for URL to complement
      the newly added URI constructor.

      I think this is important because there are many types that
      represent addresses (URI, URL, File) and there lacks a
      subtype relation between URL and URI.

      I'd also be nice with an access interface so that the
      system can attempt to construct a Channel for a URI; this
      way one wouldn't have to use these constructors oneself;
      check this out:

      public interface Access {
        ReadableByteChannel read() throws IOException;
        WritableByteChannel write() throws IOException;
      }

      URI, URL and File can then implement the Access type and
      users can easily get byte access to resources. This isn't
      perfect, but I think it's better.

      ---------- BEGIN SOURCE ----------
      I'd like to be able to do this:

        URL a = new URL("http://www.javasoft.com/x");
        File b = new File(a);

      can't be done right now. I could use URI but I want File to do the work, not
      me. So add a constructor in File that accepts a URL to complement the existing
      URI constructor -- and this is important since the URL class does not inherit
      URI class :/

      In addition this would be nice:

        public interface Access {
          ReadableByteChannel read() throws IOException;
          WritableByteChannel write() throws IOException;
        }

      Then implement this in URI, URL and File and I would be able to do:

        URL x = new URL("http://www.test.com/x");
        ReadableByteChannel rchan = x.read(); // no can do right now

      I think this improves usability a great deal, but I have no particular prefs
      regarding the way access is provided, as long as it is works on all these three
      types: URI, URL, File, in the situation where it is possible to retrieve an
      entity-body -- otherwise it would just throw an IOException.

      Please note that although it is possible to make progress without this
      improvement, it is not possible to use it for somethings without a separate
      wrapper class or using JNDI but I'm not even sure JNDI supports "uniform
      access" -- AFAIK it uses URL, File etc. objects and so I would have to have
      prior knowledge of these types to use it when all I want is to get a
      ByteChannel.
      ---------- END SOURCE ----------
      (Review ID: 139039)
      ======================================================================

            alanb Alan Bateman
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: