Class URLUtils

java.lang.Object
gov.nasa.arc.pds.tools.util.URLUtils

public class URLUtils extends Object
This class provides utilities for URL manipulation.
Author:
jagander
  • Field Details

    • TEXT_CONTENT_TYPES

      public static final List<String> TEXT_CONTENT_TYPES
  • Constructor Details

    • URLUtils

      public URLUtils()
  • Method Details

    • exists

      public static boolean exists(URI uri)
    • toSecureUrl

      public static URL toSecureUrl(URL url)
      Converts an HTTP URL to HTTPS to ensure a secure connection. Non-HTTP URLs (e.g. file://, https://) are returned unchanged.
      Parameters:
      url - the URL to convert
      Returns:
      an HTTPS URL if the input uses HTTP, otherwise the original URL
    • exists

      public static boolean exists(URL url)
    • getAlternateCaseURL

      public static URL getAlternateCaseURL(URL url)
    • getCaseUnknownURL

      public static URL getCaseUnknownURL(URL url)
    • getCaseUnknownURL

      public static URL getCaseUnknownURL(URI root, String path)
    • getCaseUnknownURL

      public static URL getCaseUnknownURL(URL root, String path)
    • getFileName

      public static String getFileName(String url)
    • getFileName

      public static String getFileName(URI uri)
    • getFileName

      public static String getFileName(URL url)
    • getParentURLString

      public static String getParentURLString(URL url)
    • getParentURL

      public static URL getParentURL(URL url)
    • getParentURL

      public static URL getParentURL(URI uri)
    • getContent

      public static URLContentsContainer getContent(URL url, long maxLength) throws IOException
      Throws:
      IOException
    • getContent

      public static URLContentsContainer getContent(URL url) throws IOException
      Throws:
      IOException
    • getContentType

      public static String getContentType(URL url) throws IOException
      Throws:
      IOException
    • getContentType

      public static String getContentType(URLConnection connection, URL url, InputStream is)
    • getCharset

      public static String getCharset(URLConnection connection, String defaultCharset)
    • getCharset

      public static String getCharset(String contentType, String defaultCharset)
    • getContentLength

      public static int getContentLength(URL url)
    • newURL

      public static URL newURL(URL base, String filename) throws MalformedURLException
      Throws:
      MalformedURLException