Class IO


  • public final class IO
    extends Object

    Since:
    1.0
    Version:
    1.0 $Revision: 8064 $
    Author:
    "Martin Krischik" «krischik@users.sourceforge.net»
    • Field Detail

      • Logger

        private static final Logger Logger

        Class logger instance.

      • TAG

        private static final String TAG

        Class logger tag.

    • Constructor Detail

      • IO

        private IO()

        Do not create

    • Method Detail

      • Read_File

        public static String Read_File​(File File)
                                throws IOException

        read file into string

        Parameters:
        File - the file to read
        Returns:
        the string
        Throws:
        IOException
      • Read_File

        public static String Read_File​(String File_Name)
                                throws IOException

        read file into string

        Parameters:
        File_Name - the filename
        Returns:
        the string
        Throws:
        IOException
      • Un_Zip_Files

        public static void Un_Zip_Files​(@NotNull
                                        File Dest_Dir,
                                        @NotNull
                                        File Source_File)
                                 throws IOException

        will extract all files from a zip into a directory. This is the simple form without support for subdirectroies.

        Parameters:
        Dest_Dir - Directory to extract to
        Source_File - zip file to extract from
        Throws:
        IOException - unzip failed
      • Zip_Files

        public static void Zip_Files​(@NotNull
                                     File Dest_File,
                                     @NotNull
                                     File Source_Dir)
                              throws IOException

        zips all files inside a directory. Does not recourse into subdirectories. Will not zip the tip file if it is created inside the same directory

        Parameters:
        Dest_File - File to zip to
        Source_Dir - Directory to zip files from
        Throws:
        IOException - zip of files failed
      • copyStream

        public static void copyStream​(@NotNull
                                      InputStream in,
                                      @NotNull
                                      OutputStream out)
                               throws IOException

        copy content of one stream into another

        Parameters:
        in - stream to copy from
        out - stream to copy to
        Throws:
        IOException - copy failed
      • deleteAll

        public static void deleteAll​(@NotNull
                                     File dir)

        delete all files in a directory.

        Parameters:
        dir - directory to clean.
      • writeToFile

        public static void writeToFile​(@Nullable
                                       @Nullable String data,
                                       @Nullable
                                       File file)
                                throws IOException

        convenience method, write string to file

        Parameters:
        data - data to write
        file - file to write to
        Throws:
        IOException
      • writeToFile

        public static void writeToFile​(@Nullable
                                       InputStream data,
                                       @Nullable
                                       File file)
                                throws IOException

        convenience method, write string to file

        Parameters:
        data - data to write
        file - file to write to
        Throws:
        IOException