Package io.hawt.util

Class IOHelper

java.lang.Object
io.hawt.util.IOHelper

public class IOHelper extends Object
A collection of IO helpers
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    close(Closeable closeable, String name, org.slf4j.Logger log)
    Closes the given resource if it is available, logging any closing exceptions to the given log.
    static void
     
    static int
    copy(Reader input, Writer output)
     
    static int
    copy(Reader input, Writer output, int bufferSize)
     
    static String
    Reads the entire reader into memory as a String
    static String
     
    static void
    write(File file, byte[] data)
     
    static void
    write(File file, byte[] data, boolean append)
    Writes the given data to the file; either in append mode or replace mode depending on the append flag.
    static void
    write(File file, String text)
    Writes the text to the given file, overwriting the previous file if it existed.
    static void
    write(File file, String text, boolean append)
    Writes the given text to the file; either in append mode or replace mode depending on the append flag.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • IOHelper

      public IOHelper()
  • Method Details

    • readFully

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

      public static String readFully(BufferedReader reader) throws IOException
      Reads the entire reader into memory as a String
      Throws:
      IOException
    • close

      public static void close(Closeable closeable, String name, org.slf4j.Logger log)
      Closes the given resource if it is available, logging any closing exceptions to the given log.
      Parameters:
      closeable - the object to close
      name - the name of the resource
      log - the log to use when reporting closure warnings, will use this class's own Logger if log == null
    • write

      public static void write(File file, String text) throws IOException
      Writes the text to the given file, overwriting the previous file if it existed.
      Throws:
      IOException
    • write

      public static void write(File file, byte[] data) throws IOException
      Throws:
      IOException
    • write

      public static void write(File file, String text, boolean append) throws IOException
      Writes the given text to the file; either in append mode or replace mode depending on the append flag.
      Throws:
      IOException
    • write

      public static void write(File file, byte[] data, boolean append) throws IOException
      Writes the given data to the file; either in append mode or replace mode depending on the append flag.
      Throws:
      IOException
    • copy

      public static int copy(Reader input, Writer output) throws IOException
      Throws:
      IOException
    • copy

      public static int copy(Reader input, Writer output, int bufferSize) throws IOException
      Throws:
      IOException
    • copy

      public static void copy(InputStream is, OutputStream os) throws IOException
      Throws:
      IOException