Package net.sf.jnati

Class FileUtils


  • public class FileUtils
    extends java.lang.Object
    Author:
    Sam Adams
    • Constructor Summary

      Constructors 
      Constructor Description
      FileUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void copyStreamToStream​(java.io.InputStream in, java.io.OutputStream out)
      Copys the entire contents of an InputStream to an OutputStream.
      static boolean delTree​(java.io.File dir)
      Deletes a directory and its contents.
      static java.io.File getTmpDir()
      Creates a temporary directory in the default system location.
      static java.io.File getTmpDir​(java.io.File root)
      Creates a temporary directory in the specified location, or the default system location if the specified location is set to null.
      static java.io.File getTmpDir​(java.lang.String path)
      Creates a temporary directory in the specified location, or the default system location if the specified location is set to null.
      static byte[] readBytes​(java.io.InputStream in)
      Reads the entire contents of an InputStream into an array of bytes.
      static java.lang.String readString​(java.io.Reader in)
      Reads entire contents of reader into a string.
      static void writeStreamToFile​(java.io.InputStream in, java.io.File file)
      Writes the contents of an input stream to a file.
      static void writeString​(java.io.File file, java.lang.String string)
      Writes the contents of a string to a file.
      • Methods inherited from class java.lang.Object

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

      • FileUtils

        public FileUtils()
    • Method Detail

      • getTmpDir

        public static java.io.File getTmpDir()
                                      throws java.io.IOException
        Creates a temporary directory in the default system location.
        Returns:
        Throws:
        java.io.IOException
      • getTmpDir

        public static java.io.File getTmpDir​(java.lang.String path)
                                      throws java.io.IOException
        Creates a temporary directory in the specified location, or the default system location if the specified location is set to null.
        Parameters:
        path -
        Returns:
        Throws:
        java.io.IOException
      • getTmpDir

        public static java.io.File getTmpDir​(java.io.File root)
                                      throws java.io.IOException
        Creates a temporary directory in the specified location, or the default system location if the specified location is set to null.
        Parameters:
        path -
        Returns:
        Throws:
        java.io.IOException
      • delTree

        public static boolean delTree​(java.io.File dir)
        Deletes a directory and its contents.
        Parameters:
        dir -
        Returns:
        True on success, false on failure.
      • writeStreamToFile

        public static void writeStreamToFile​(java.io.InputStream in,
                                             java.io.File file)
                                      throws java.io.IOException
        Writes the contents of an input stream to a file. If the file already exists, it will be overwritten.
        Parameters:
        in - Input stream providing file contents
        file - File to write to
        Throws:
        java.io.IOException
      • copyStreamToStream

        public static void copyStreamToStream​(java.io.InputStream in,
                                              java.io.OutputStream out)
                                       throws java.io.IOException
        Copys the entire contents of an InputStream to an OutputStream.
        Parameters:
        in -
        out -
        Throws:
        java.io.IOException
      • readBytes

        public static byte[] readBytes​(java.io.InputStream in)
                                throws java.io.IOException
        Reads the entire contents of an InputStream into an array of bytes.
        Parameters:
        in -
        Returns:
        Throws:
        java.io.IOException
      • readString

        public static java.lang.String readString​(java.io.Reader in)
                                           throws java.io.IOException
        Reads entire contents of reader into a string.
        Parameters:
        in -
        Returns:
        Throws:
        java.io.IOException
      • writeString

        public static void writeString​(java.io.File file,
                                       java.lang.String string)
                                throws java.io.IOException
        Writes the contents of a string to a file. If the file already exists it is over-written.
        Parameters:
        file -
        string -
        Throws:
        java.io.IOException