Class AbstractOrigin.ChannelOrigin

    • Constructor Detail

      • ChannelOrigin

        public ChannelOrigin​(java.nio.channels.Channel origin)
        Constructs a new instance for the given origin.
        Parameters:
        origin - The origin, not null.
        Throws:
        java.lang.NullPointerException - if origin is null.
    • Method Detail

      • getChannel

        protected java.nio.channels.Channel getChannel​(java.nio.file.OpenOption... options)
                                                throws java.io.IOException
        Gets this origin as a Channel, if possible.

        No conversion should occur when calling this method.

        Overrides:
        getChannel in class AbstractOrigin<java.nio.channels.Channel,​AbstractOrigin.ChannelOrigin>
        Parameters:
        options - Options specifying how a file-based origin is opened, ignored otherwise.
        Returns:
        A new Channel on the origin.
        Throws:
        java.io.IOException - If an I/O error occurs.
        See Also:
        AbstractOrigin.getChannel(Class, OpenOption...)
      • getInputStream

        public java.io.InputStream getInputStream​(java.nio.file.OpenOption... options)
                                           throws java.io.IOException
        Description copied from class: AbstractOrigin
        Gets this origin as an InputStream, if possible.
        Overrides:
        getInputStream in class AbstractOrigin<java.nio.channels.Channel,​AbstractOrigin.ChannelOrigin>
        Parameters:
        options - options specifying how the file is opened
        Returns:
        this origin as an InputStream, if possible.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • getOutputStream

        public java.io.OutputStream getOutputStream​(java.nio.file.OpenOption... options)
                                             throws java.io.IOException
        Description copied from class: AbstractOrigin
        Gets this origin as an OutputStream, if possible.
        Overrides:
        getOutputStream in class AbstractOrigin<java.nio.channels.Channel,​AbstractOrigin.ChannelOrigin>
        Parameters:
        options - options specifying how the file is opened
        Returns:
        this origin as an OutputStream, if possible.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • getReader

        public java.io.Reader getReader​(java.nio.charset.Charset charset)
                                 throws java.io.IOException
        Description copied from class: AbstractOrigin
        Gets a new Reader on the origin, buffered by default.
        Overrides:
        getReader in class AbstractOrigin<java.nio.channels.Channel,​AbstractOrigin.ChannelOrigin>
        Parameters:
        charset - the charset to use for decoding, null maps to the default Charset.
        Returns:
        a new Reader on the origin.
        Throws:
        java.io.IOException - if an I/O error occurs opening the file.
      • getWriter

        public java.io.Writer getWriter​(java.nio.charset.Charset charset,
                                        java.nio.file.OpenOption... options)
                                 throws java.io.IOException
        Description copied from class: AbstractOrigin
        Gets a new Writer on the origin, buffered by default.
        Overrides:
        getWriter in class AbstractOrigin<java.nio.channels.Channel,​AbstractOrigin.ChannelOrigin>
        Parameters:
        charset - the charset to use for encoding
        options - options specifying how the file is opened
        Returns:
        a new Writer on the origin.
        Throws:
        java.io.IOException - if an I/O error occurs opening or creating the file.
      • size

        public long size()
                  throws java.io.IOException
        Description copied from class: AbstractOrigin
        Gets the size of the origin, if possible.
        Overrides:
        size in class AbstractOrigin<java.nio.channels.Channel,​AbstractOrigin.ChannelOrigin>
        Returns:
        the size of the origin in bytes or characters.
        Throws:
        java.io.IOException - if an I/O error occurs.