Package ipsk.io

Class StreamCopy


  • public class StreamCopy
    extends java.lang.Object
    Utility methods to copy streams and files.
    Author:
    K.Jaensch, klausj@phonetik.uni-muenchen.de
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEF_BUF_SIZE  
      static java.nio.charset.Charset DEF_CHARSET  
    • Constructor Summary

      Constructors 
      Constructor Description
      StreamCopy()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void append​(java.io.InputStream is, java.io.OutputStream os)
      Reads data from input stream and appends it to the output stream.
      static void copy​(java.io.File src, java.io.File dst)  
      static void copy​(java.io.File src, java.io.File dst, boolean createParentDirectories)  
      static void copy​(java.io.InputStream src, java.io.File dst, boolean createParentDirectories)  
      static void copy​(java.io.InputStream is, java.io.OutputStream os)
      Reads data from input stream and writes it to output stream.
      static void copy​(java.io.InputStream is, java.io.OutputStream os, boolean closeOutStream)  
      static void copy​(java.io.InputStream is, java.io.OutputStream os, boolean closeOutStream, int bufSize)  
      static void copy​(java.io.InputStream is, java.io.OutputStream os, int bufSize)  
      static void copyChars​(java.io.Reader is, java.io.Writer os)  
      static java.lang.String readTextFile​(java.io.File textFile, java.nio.charset.Charset charset)  
      static java.lang.String readTextStream​(java.io.InputStream textStream, java.nio.charset.Charset charset)  
      static void toSystemErr​(java.io.InputStream is)  
      static void toSystemOut​(java.io.InputStream is)  
      static void writeTextFile​(java.lang.String text, java.io.File file, java.nio.charset.Charset charset)  
      static void writeUTF8TextFile​(java.lang.String text, java.io.File file)  
      • Methods inherited from class java.lang.Object

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

      • DEF_BUF_SIZE

        public static int DEF_BUF_SIZE
      • DEF_CHARSET

        public static java.nio.charset.Charset DEF_CHARSET
    • Constructor Detail

      • StreamCopy

        public StreamCopy()
    • Method Detail

      • copy

        public static void copy​(java.io.File src,
                                java.io.File dst)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • copy

        public static void copy​(java.io.File src,
                                java.io.File dst,
                                boolean createParentDirectories)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • copy

        public static void copy​(java.io.InputStream src,
                                java.io.File dst,
                                boolean createParentDirectories)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • append

        public static void append​(java.io.InputStream is,
                                  java.io.OutputStream os)
                           throws java.io.IOException
        Reads data from input stream and appends it to the output stream. Only the input stream is closed at end of input stream data.
        Parameters:
        is - input stream
        os - ouput stream
        Throws:
        java.io.IOException
      • copy

        public static void copy​(java.io.InputStream is,
                                java.io.OutputStream os)
                         throws java.io.IOException
        Reads data from input stream and writes it to output stream. Input and output stream are closed at end of input stream data.
        Parameters:
        is -
        os -
        Throws:
        java.io.IOException
      • copy

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

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

        public static void copy​(java.io.InputStream is,
                                java.io.OutputStream os,
                                boolean closeOutStream,
                                int bufSize)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • copyChars

        public static void copyChars​(java.io.Reader is,
                                     java.io.Writer os)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • writeUTF8TextFile

        public static void writeUTF8TextFile​(java.lang.String text,
                                             java.io.File file)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • writeTextFile

        public static void writeTextFile​(java.lang.String text,
                                         java.io.File file,
                                         java.nio.charset.Charset charset)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • readTextStream

        public static java.lang.String readTextStream​(java.io.InputStream textStream,
                                                      java.nio.charset.Charset charset)
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • readTextFile

        public static java.lang.String readTextFile​(java.io.File textFile,
                                                    java.nio.charset.Charset charset)
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • toSystemOut

        public static void toSystemOut​(java.io.InputStream is)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • toSystemErr

        public static void toSystemErr​(java.io.InputStream is)
                                throws java.io.IOException
        Throws:
        java.io.IOException