Class NetscapeCookieFile

    • Constructor Detail

      • NetscapeCookieFile

        public NetscapeCookieFile​(Path path)
        Parameters:
        path - where to find the cookie file
    • Method Detail

      • getPath

        public Path getPath()
        Path to the underlying cookie file.
        Returns:
        the path
      • getCookies

        public Set<HttpCookie> getCookies​(boolean refresh)
        Return all cookies from the underlying cookie file.
        Parameters:
        refresh - if true updates the list from the underlying cookie file if it has been modified since the last read otherwise returns the current transient state. In case the cookie file has never been read before will always read from the underlying file disregarding the value of this parameter.
        Returns:
        all cookies (may contain session cookies as well). This does not return a copy of the list but rather the original one. Every addition to the returned list can afterwards be persisted via write(URL). Errors in the underlying file will not lead to exceptions but rather to an empty set being returned and the underlying error being logged.
      • write

        public void write​(URL url)
                   throws IOException,
                          InterruptedException
        Writes all the cookies being maintained in the set being returned by getCookies(boolean) to the underlying file.

        Session-cookies will not be persisted.

        Parameters:
        url - url for which to write the cookies (important to derive default values for non-explicitly set attributes)
        Throws:
        IOException - if the underlying cookie file could not be read or written or a problem with the lock file
        InterruptedException - if the thread is interrupted while waiting for the lock