Class ResourceReader

java.lang.Object
com.github.natche.gravatarjavaclient.utils.ResourceReader

public final class ResourceReader extends Object
A class for reading resources given a BufferedReader.
  • Method Details

    • from

      public static ResourceReader from(BufferedReader resourceReader)
      Constructs and returns a new ResourceReader from the provided reader.
      Parameters:
      resourceReader - the buffered reader to read the resource
      Returns:
      a new ResourceReader object
      Throws:
      NullPointerException - if the provided resourceReader is null
    • isValidFilename

      public static boolean isValidFilename(String filename)
      Returns whether the provided filename is valid for this operating system.
      Parameters:
      filename - the filename
      Returns:
      whether the provided filename is valid for this operating system
      Throws:
      NullPointerException - if the provided filename is null
      IllegalArgumentException - if the provided filename is empty
    • skipHeaders

      public ResourceReader skipHeaders() throws IOException
      Skips any headers of the encapsulated reader.
      Returns:
      this reader
      Throws:
      IOException - if an IO exception occurs
    • readChunkedBody

      public String readChunkedBody() throws IOException
      Reads a chunked body from encapsulated reader.
      Returns:
      the complete response body
      Throws:
      IOException - if an IO exception occurs
      NumberFormatException - if the chunk size cannot be parsed
    • hashCode

      public int hashCode()
      Returns a hashcode representation of this object.
      Overrides:
      hashCode in class Object
      Returns:
      a hashcode representation of this object
    • toString

      public String toString()
      Returns a string representation of this object.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this object
    • equals

      public boolean equals(Object o)
      Returns whether the provided object is equal to this.
      Overrides:
      equals in class Object
      Parameters:
      o - the other object
      Returns:
      whether the provided object is equal to this