Class InputOutput

java.lang.Object
slash.common.io.InputOutput

public class InputOutput extends Object
As a pipe reads from input and writes to output.
Author:
Christian Pesch
  • Field Details

  • Constructor Details

    • InputOutput

      public InputOutput()
  • Method Details

    • copyAndClose

      public static void copyAndClose(InputStream inputStream, OutputStream outputStream) throws IOException
      Throws:
      IOException
    • copyAndClose

      public static void copyAndClose(Reader reader, Writer writer) throws IOException
      Throws:
      IOException
    • readBytes

      public static byte[] readBytes(InputStream input) throws IOException
      Throws:
      IOException
    • readFileToString

      public static String readFileToString(File file) throws IOException
      Throws:
      IOException
    • readAsReaderPreferringUtf8

      public static Reader readAsReaderPreferringUtf8(InputStream input) throws IOException
      Returns a Reader for legacy/garbled XML that carries no encoding declaration: decodes as UTF-8 when the bytes are valid UTF-8, otherwise falls back to Windows-1252 (the common legacy code page). Deterministic and independent of the platform default charset, which changed to UTF-8 in JDK 18 (JEP 400) and previously made this depend on the host locale.
      Throws:
      IOException