Package io.hawt.util

Class IOHelper


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

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

      Constructors 
      Constructor Description
      IOHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void close​(java.io.Closeable closeable, java.lang.String name, org.slf4j.Logger log)
      Closes the given resource if it is available, logging any closing exceptions to the given log.
      static void copy​(java.io.InputStream is, java.io.OutputStream os)  
      static int copy​(java.io.Reader input, java.io.Writer output)  
      static int copy​(java.io.Reader input, java.io.Writer output, int bufferSize)  
      static java.lang.String readFully​(java.io.BufferedReader reader)
      Reads the entire reader into memory as a String
      static java.lang.String readFully​(java.io.File file)  
      static void write​(java.io.File file, byte[] data)  
      static void write​(java.io.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​(java.io.File file, java.lang.String text)
      Writes the text to the given file, overwriting the previous file if it existed.
      static void write​(java.io.File file, java.lang.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
    • Constructor Detail

      • IOHelper

        public IOHelper()
    • Method Detail

      • readFully

        public static java.lang.String readFully​(java.io.File file)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readFully

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

        public static void close​(java.io.Closeable closeable,
                                 java.lang.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​(java.io.File file,
                                 java.lang.String text)
                          throws java.io.IOException
        Writes the text to the given file, overwriting the previous file if it existed.
        Throws:
        java.io.IOException
      • write

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

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

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

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

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

        public static void copy​(java.io.InputStream is,
                                java.io.OutputStream os)
                         throws java.io.IOException
        Throws:
        java.io.IOException