Class StringResource

    • Constructor Detail

      • StringResource

        public StringResource()
        Instantiates a new string resource.
      • StringResource

        public StringResource​(String resource)

        Creates a Resource that is a String.

        Parameters:
        resource - The string contents.
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • readToString

        public String readToString()
                            throws IOException
        Description copied from interface: Resource

        Reads in the resource as a String using UTF-8.

        Specified by:
        readToString in interface Resource
        Returns:
        A string representing the contents of the file.
        Throws:
        IOException - the io exception
      • readBytes

        public byte[] readBytes()
                         throws IOException
        Description copied from interface: Resource

        Reads the resource into an array of bytes.

        Specified by:
        readBytes in interface Resource
        Returns:
        An array of bytes representing the content of the resource.
        Throws:
        IOException - the io exception
      • reader

        public Reader reader()
                      throws IOException
        Description copied from interface: Resource
        Opens a reader using guessing the encoding and falling back to the default on the resource.
        Specified by:
        reader in interface Resource
        Returns:
        A reader
        Throws:
        IOException - the io exception
      • readLines

        public List<String> readLines()
                               throws IOException
        Description copied from interface: Resource
        Reads the complete resource in as text breaking it into lines based on the newline character
        Specified by:
        readLines in interface Resource
        Returns:
        A list of string representing the contents of the file.
        Throws:
        IOException - the io exception
      • append

        public Resource append​(String content)
                        throws IOException
        Description copied from interface: Resource

        Appends the given string content to the resource.

        Specified by:
        append in interface Resource
        Parameters:
        content - The content to append
        Returns:
        the resource
        Throws:
        IOException - the io exception
      • append

        public Resource append​(byte[] byteArray)
                        throws IOException
        Description copied from interface: Resource

        Appends the given byte array content to the resource.

        Specified by:
        append in interface Resource
        Parameters:
        byteArray - The content to append
        Returns:
        the resource
        Throws:
        IOException - the io exception
      • exists

        public boolean exists()
        Description copied from interface: Resource
        Exists boolean.
        Specified by:
        exists in interface Resource
        Returns:
        True if the resource exists, False if the resource does not exist.