Class HmSave

  • All Implemented Interfaces:
    Home

    public final class HmSave
    extends Object
    implements Home
    Home that defines the logic of saving different types of data to files.
    Since:
    0.37.0
    • Constructor Detail

      • HmSave

        public HmSave​(org.cactoos.BiProc<org.cactoos.Input,​Path> save)
        Ctor.
        Parameters:
        save - BiProc for saving Input to file.
    • Method Detail

      • save

        public void save​(String str,
                         Path path)
                  throws IOException
        Description copied from interface: Home
        Saving string.
        Specified by:
        save in interface Home
        Parameters:
        str - String
        path - Cwd-relative path to file
        Throws:
        IOException - If fails
      • save

        public void save​(org.cactoos.Text txt,
                         Path path)
                  throws IOException
        Description copied from interface: Home
        Saving text.
        Specified by:
        save in interface Home
        Parameters:
        txt - Text
        path - Cwd-relative path to file
        Throws:
        IOException - If fails
      • save

        public void save​(InputStream stream,
                         Path path)
                  throws IOException
        Description copied from interface: Home
        Saving stream.
        Specified by:
        save in interface Home
        Parameters:
        stream - Input stream
        path - Cwd-relative path to file
        Throws:
        IOException - If fails
      • save

        public void save​(byte[] bytes,
                         Path path)
                  throws IOException
        Description copied from interface: Home
        Saving bytes.
        Specified by:
        save in interface Home
        Parameters:
        bytes - Byte array
        path - Cwd-relative path to file
        Throws:
        IOException - If fails
      • save

        public void save​(org.cactoos.Input input,
                         Path path)
                  throws IOException
        Description copied from interface: Home
        Saving input.
        Specified by:
        save in interface Home
        Parameters:
        input - Input
        path - Cwd-relative path to file
        Throws:
        IOException - If fails
      • exists

        public boolean exists​(Path path)
        Description copied from interface: Home
        Check if exists.
        Specified by:
        exists in interface Home
        Parameters:
        path - Cwd-relative path to file
        Returns:
        True if exists
      • load

        public org.cactoos.Bytes load​(Path path)
                               throws IOException
        Description copied from interface: Home
        Load bytes from file by path.
        Specified by:
        load in interface Home
        Parameters:
        path - Cwd-relative path to file
        Returns:
        Bytes of file
        Throws:
        IOException - if method can't find the file by path or if some exception happens during reading the file
      • absolute

        public Path absolute​(Path path)
        Description copied from interface: Home
        Absolute path to a file.
        Specified by:
        absolute in interface Home
        Parameters:
        path - Cwd-relative path to file
        Returns:
        Absolute path
      • onlyRelative

        public Path onlyRelative​(Path path)
        Description copied from interface: Home
        Verifies that given path is relative and throws exception.
        Specified by:
        onlyRelative in interface Home
        Parameters:
        path - Path to be verified
        Returns:
        Given path if it's relative