Class SimpleFileWriter

java.lang.Object
com.compomics.util.io.flat.SimpleFileWriter
All Implemented Interfaces:
AutoCloseable

public class SimpleFileWriter
extends Object
implements AutoCloseable
Simple gz file writer that is thread safe and throws exceptions as runtime exceptions.
Author:
Marc Vaudel
  • Constructor Details

    • SimpleFileWriter

      public SimpleFileWriter​(File file, boolean gz)
      Constructor.
      Parameters:
      file - The file to write to.
      gz - Boolean indicating whether the output should be gzipped.
  • Method Details

    • writeLine

      public void writeLine​(String... elements)
      Writes a new line using the give elements. Elements are separated using the separator in the properties class.
      Parameters:
      elements - The line elements to write.
    • writeLine

      public void writeLine​(String line)
      Writes a new line.
      Parameters:
      line - The line to write.
    • write

      public void write​(char[] buffer, int offset, int length)
      Writes a a buffer of characters to the file.
      Parameters:
      buffer - The buffer to write.
      offset - The offset from which to start reading characters.
      length - The maximal number of characters to write
    • newLine

      public void newLine()
      Appends a new line to the output.
    • write

      public void write​(String text)
      Writes text.
      Parameters:
      text - The text to write.
    • write

      public void write​(String text, boolean newLine)
      Writes text.
      Parameters:
      text - The text to write.
      newLine - Boolean indicating whether an end of line should be appended.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • getWriter

      public BufferedWriter getWriter()
      Returns the underlying buffered writer.
      Returns:
      The underlying buffered writer.