Class FileHandler

java.lang.Object
java.net.URLStreamHandler
libcore.net.url.FileHandler

public class FileHandler
extends URLStreamHandler
This is the handler that is responsible for reading files from the file system.
  • Constructor Details

    • FileHandler

      public FileHandler()
  • Method Details

    • openConnection

      public URLConnection openConnection​(URL url) throws IOException
      Returns a connection to the a file pointed by this URL in the file system
      Specified by:
      openConnection in class URLStreamHandler
      Parameters:
      url - URL The URL to which the connection is pointing to
      Returns:
      A connection to the resource pointed by this url.
      Throws:
      IOException - if an I/O error occurs during opening the connection.
    • openConnection

      public URLConnection openConnection​(URL url, Proxy proxy) throws IOException
      The behavior of this method is the same as openConnection(URL). proxy is not used in FileURLConnection.
      Overrides:
      openConnection in class URLStreamHandler
      Parameters:
      url - the URL which the connection is pointing to
      proxy - Proxy
      Returns:
      a connection to the resource pointed by this url.
      Throws:
      IOException - if this handler fails to establish a connection.
      IllegalArgumentException - if the url argument is null.
      UnsupportedOperationException - if the protocol handler doesn't support this method.
    • parseURL

      protected void parseURL​(URL url, String spec, int start, int end)
      Parse the stringstr into URL u which already have the context properties. The string generally have the following format:
      /c:/windows/win.ini
      .
      Overrides:
      parseURL in class URLStreamHandler
      Parameters:
      url - The URL object that's parsed into
      spec - The string equivalent of the specification URL
      start - The index in the spec string from which to begin parsing
      end - The index to stop parsing
      See Also:
      URLStreamHandler.toExternalForm(URL), URL