Class NioUtils


  • @Deprecated
    public class NioUtils
    extends java.lang.Object
    Deprecated.
    Will be removed to favor lower-level network extensions allowing more control at the Restlet API level.
    Utility methods for NIO processing.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private NioUtils()
      Deprecated.
      Private constructor to ensure that the class acts as a true utility class i.e.
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static int copy​(java.nio.ByteBuffer sourceBuffer, java.nio.ByteBuffer targetBuffer, long maxCopied)
      Deprecated.
      Writes the source buffer to the target buffer, up to a maximum number of bytes.
      static void copy​(java.nio.channels.FileChannel fileChannel, java.nio.channels.WritableByteChannel writableChannel)
      Deprecated.
      Writes the representation to a byte channel.
      static void copy​(java.nio.channels.ReadableByteChannel readableChannel, java.io.OutputStream outputStream)
      Deprecated.
      Writes a NIO readable channel to a BIO output stream.
      static void waitForState​(java.nio.channels.SelectableChannel selectableChannel, int operations)
      Deprecated.
      Waits for the given channel to be ready for a specific operation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NioUtils

        private NioUtils()
        Deprecated.
        Private constructor to ensure that the class acts as a true utility class i.e. it isn't instantiable and extensible.
    • Method Detail

      • copy

        public static int copy​(java.nio.ByteBuffer sourceBuffer,
                               java.nio.ByteBuffer targetBuffer,
                               long maxCopied)
        Deprecated.
        Writes the source buffer to the target buffer, up to a maximum number of bytes.
        Parameters:
        sourceBuffer - The source buffer.
        targetBuffer - The target buffer.
        maxCopied - The maximum number of bytes copied by this call or 0 for unlimited length.
        Returns:
        The number of bytes added to the target buffer.
      • copy

        public static void copy​(java.nio.channels.FileChannel fileChannel,
                                java.nio.channels.WritableByteChannel writableChannel)
                         throws java.io.IOException
        Deprecated.
        Writes the representation to a byte channel. Optimizes using the file channel transferTo method.
        Parameters:
        fileChannel - The readable file channel.
        writableChannel - A writable byte channel.
        Throws:
        java.io.IOException
      • copy

        public static void copy​(java.nio.channels.ReadableByteChannel readableChannel,
                                java.io.OutputStream outputStream)
                         throws java.io.IOException
        Deprecated.
        Writes a NIO readable channel to a BIO output stream.
        Parameters:
        readableChannel - The readable channel.
        outputStream - The output stream.
        Throws:
        java.io.IOException
      • waitForState

        public static void waitForState​(java.nio.channels.SelectableChannel selectableChannel,
                                        int operations)
                                 throws java.io.IOException
        Deprecated.
        Waits for the given channel to be ready for a specific operation.
        Parameters:
        selectableChannel - The channel to monitor.
        operations - The operations to be ready to do.
        Throws:
        java.io.IOException