Module org.firebirdsql.jaybird
Package org.firebirdsql.jaybird.util

# Class IOUtils

java.lang.Object
org.firebirdsql.jaybird.util.IOUtils

public final class IOUtils extends Object
Utility methods for stream and byte array conversions.

Since:
  3.0
Author:
  Mark Rotteveel

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static byte[]`
  `toBytes(InputStream in, int length)`
  Reads `length` bytes from `in` to a byte array, or until EOF.
  `static String`
  `toString(Reader in, int length)`
  Reads `length` characters from `in` to a string, or until EOF.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### toBytes

    public static byte[] toBytes(InputStream in, int length) throws IOException
    Reads `length` bytes from `in` to a byte array, or until EOF.
    Parameters:
      `in` - input stream
      `length` - number of bytes to read (or `-1` to read until EOF)
    Returns:
      byte array; length is the actual number of bytes read when EOF was reached before `length`
    Throws:
      `IOException` - for exceptions reading from `in`

  - ### toString

    public static String toString(Reader in, int length) throws IOException
    Reads `length` characters from `in` to a string, or until EOF.
    Parameters:
      `in` - input stream
      `length` - number of characters to read (or `-1` to read until EOF)
    Returns:
      string; length is the actual number of characters read when EOF was reached before `length`
    Throws:
      `IOException` - for exceptions reading from `in`