Module file.worker

Class WriteFileExtensions

java.lang.Object
io.github.astrapi69.file.write.WriteFileExtensions

public final class WriteFileExtensions extends Object
The class WriteFileExtensions provides methods for writing in files.
  • Method Details

    • readSourceFileAndWriteDestFile

      public static void readSourceFileAndWriteDestFile(String srcfile, String destFile) throws IOException
      Writes the source file with the best performance to the destination file.
      Parameters:
      srcfile - The source file.
      destFile - The destination file.
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • string2File

      public static void string2File(String string2write, String nameOfFile) throws IOException
      The Method string2File() writes a String to the file.
      Parameters:
      string2write - The String to write into the file.
      nameOfFile - The path to the file and name from the file from where we want to write the String.
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write

      public static void write(InputStream inputStream, OutputStream outputStream) throws FileNotFoundException, IOException
      Writes the given input stream to the output stream.
      Parameters:
      inputStream - the input stream
      outputStream - the output stream
      Throws:
      FileNotFoundException - is thrown if the given file is not found
      IOException - Signals that an I/O exception has occurred.
    • write2File

      public static void write2File(Reader reader, Writer writer) throws IOException
      The Method write2File() reads from an opened Reader and writes it to the opened Writer.
      Parameters:
      reader - The opened Reader.
      writer - The opened Writer.
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write2File

      public static void write2File(String inputFile, String outputFile) throws IOException
      The Method write2File(String, String) copys a file from one filename to another.
      Parameters:
      inputFile - The Name from the File to read and copy.
      outputFile - The Name from the File to write into.
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • write2File

      public static void write2File(String inputFile, Writer writer) throws FileNotFoundException, IOException
      The Method write2File() writes the File into the PrintWriter.
      Parameters:
      inputFile - The Name from the File to read and copy.
      writer - The PrintWriter to write into.
      Throws:
      FileNotFoundException - is thrown if an attempt to open the file denoted by a specified pathname has failed.
      IOException - Signals that an I/O exception has occurred.
    • write2FileWithBuffer

      public static void write2FileWithBuffer(String inputFile, String outputFile) throws FileNotFoundException, IOException
      The Method write2FileWithBuffer() copy the content from one file to another. It use a buffer as the name says.
      Parameters:
      inputFile - The Path to the File and name from the file from where we read.
      outputFile - The Path to the File and name from the file from where we want to write.
      Throws:
      FileNotFoundException - is thrown if an attempt to open the file denoted by a specified pathname has failed.
      IOException - Signals that an I/O exception has occurred.
    • writeByteArrayToFile

      public static void writeByteArrayToFile(File file, byte[] byteArray) throws IOException
      Writes the given byte array to the given file.
      Parameters:
      file - The file.
      byteArray - The byte array.
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • writeByteArrayToFile

      public static void writeByteArrayToFile(String filename, byte[] byteArray) throws IOException
      Writes the given byte array to a file.
      Parameters:
      filename - The filename from the file.
      byteArray - The byte array.
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • writeLinesToFile

      public static void writeLinesToFile(Collection<String> lines, File output) throws FileNotFoundException, IOException
      Writes the input from the lines into the file.
      Parameters:
      lines - The lines to write to file.
      output - The output-file.
      Throws:
      FileNotFoundException - is thrown if an attempt to open the file denoted by a specified pathname has failed.
      IOException - Signals that an I/O exception has occurred.
    • writeLinesToFile

      public static void writeLinesToFile(Collection<String> lines, File output, String encoding) throws FileNotFoundException, IOException
      Writes the input from the lines into the file.
      Parameters:
      lines - The lines to write to file.
      output - The output-file.
      encoding - the encoding
      Throws:
      FileNotFoundException - is thrown if an attempt to open the file denoted by a specified pathname has failed.
      IOException - Signals that an I/O exception has occurred.
    • writeLinesToFile

      public static void writeLinesToFile(File output, List<String> input, String encoding) throws FileNotFoundException, IOException
      Writes the input from the collection into the file.
      Parameters:
      output - The file to write the lines.
      input - The list with the input data.
      encoding - The encoding.
      Throws:
      FileNotFoundException - is thrown if an attempt to open the file denoted by a specified pathname has failed.
      IOException - Signals that an I/O exception has occurred.
    • writeProperties2File

      public static void writeProperties2File(String filename, Properties properties) throws IOException
      The Method writeProperties2File(String, Properties) writes the Properties to the file.
      Parameters:
      filename - The filename from the file to write the properties.
      properties - The properties.
      Throws:
      IOException - Signals that an I/O exception has occurred.