Class UtilIO

java.lang.Object
org.apache.ofbiz.base.util.UtilIO

public final class UtilIO extends Object
  • Method Details

    • copy

      public static void copy(Reader reader, Appendable out) throws IOException
      Copy a Reader to an Appendable.
      Parameters:
      reader - the Reader to copy from
      out - the Appendable to copy to
      Throws:
      IOException - if an error occurs
    • readString

      public static String readString(byte[] bytes)
      Convert a byte array to a string; consistently uses \n line endings in java. This uses a default UTF-8 charset.
      Parameters:
      bytes - the array of bytes to convert
      Returns:
      the converted string, with platform line endings converted to \n
    • readString

      public static String readString(byte[] bytes, int offset, int length)
      Convert a byte array to a string; consistently uses \n line endings in java. The conversion is limited to the specified offset/length pair, and uses a default UTF-8 charset.
      Parameters:
      bytes - the array of bytes to convert
      offset - the start of the conversion
      length - how many bytes to convert
      Returns:
      the converted string, with platform line endings converted to \n
    • readString

      public static String readString(byte[] bytes, String charset)
      Convert a byte array to a string; consistently uses \n line endings in java. The conversion is limited to the specified offset/length pair, and uses the requested charset to decode the bytes.
      Parameters:
      bytes - the array of bytes to convert
      charset - the charset to use to convert the raw bytes
      Returns:
      the converted string, with platform line endings converted to \n
    • readString

      public static String readString(byte[] bytes, int offset, int length, String charset)
      Convert a byte array to a string; consistently uses \n line endings in java. The conversion is limited to the specified offset/length pair, and uses the requested charset to decode the bytes.
      Parameters:
      bytes - the array of bytes to convert
      offset - the start of the conversion
      length - how many bytes to convert
      charset - the charset to use to convert the raw bytes
      Returns:
      the converted string, with platform line endings converted to \n
    • readString

      public static String readString(byte[] bytes, Charset charset)
      Convert a byte array to a string, consistently uses \n line endings in java. The specified charset is used to decode the bytes.
      Parameters:
      bytes - the array of bytes to convert
      charset - the charset to use to convert the raw bytes
      Returns:
      the converted string, with platform line endings converted to \n
    • readString

      public static String readString(byte[] bytes, int offset, int length, Charset charset)
      Convert a byte array to a string, consistently uses \n line endings in java. The conversion is limited to the specified offset/length pair, and uses the requested charset to decode the bytes.
      Parameters:
      bytes - the array of bytes to convert
      offset - the start of the conversion
      length - how many bytes to convert
      charset - the charset to use to convert the raw bytes
      Returns:
      the converted string, with platform line endings converted to \n
    • readString

      public static String readString(InputStream stream) throws IOException
      Convert an InputStream to a string; consistently uses \n line endings in java. This uses a default UTF-8 charset.
      Parameters:
      stream - the stream of bytes to convert
      Returns:
      the converted string, with platform line endings converted to \n
      Throws:
      IOException
    • readString

      public static String readString(InputStream stream, String charset) throws IOException
      Convert an InputStream to a string; consistently uses \n line endings in java. This uses a default UTF-8 charset.
      Parameters:
      stream - the stream of bytes to convert
      charset - the charset to use to convert the raw bytes
      Returns:
      the converted string, with platform line endings converted to \n
      Throws:
      IOException
    • readString

      public static String readString(InputStream stream, Charset charset) throws IOException
      Convert an InputStream to a string; consistently uses \n line endings in java. This uses a default UTF-8 charset.
      Parameters:
      stream - the stream of bytes to convert
      charset - the charset to use to convert the raw bytes
      Returns:
      the converted string, with platform line endings converted to \n
      Throws:
      IOException
    • readString

      public static String readString(Reader reader) throws IOException
      Convert an Reader to a string; consistently uses \n line endings in java.
      Parameters:
      reader - the stream of characters convert
      Returns:
      the converted string, with platform line endings converted to \n
      Throws:
      IOException
    • writeString

      public static void writeString(File file, String value) throws IOException
      Convert a \n string to a platform encoding. This uses a default UTF-8 charset.
      Parameters:
      file - where to write the converted bytes to
      value - the value to write
      Throws:
      IOException
    • writeString

      public static void writeString(OutputStream out, String value) throws IOException
      Convert a \n string to a platform encoding. This uses a default UTF-8 charset.
      Parameters:
      out - where to write the converted bytes to
      value - the value to write
      Throws:
      IOException
    • writeString

      public static void writeString(OutputStream out, String charset, String value) throws IOException
      Convert a \n string to a platform encoding. This uses the specified charset to extract the raw bytes.
      Parameters:
      out - where to write the converted bytes to
      charset - the charset to use to convert the raw bytes
      value - the value to write
      Throws:
      IOException
    • writeString

      public static void writeString(OutputStream out, Charset charset, String value) throws IOException
      Convert a \n string to a platform encoding. This uses the specified charset to extract the raw bytes.
      Parameters:
      out - where to write the converted bytes to
      charset - the charset to use to convert the raw bytes
      value - the value to write
      Throws:
      IOException