Class FileService


  • public class FileService
    extends Object
    A class to allow reading and writing text file.
    • Constructor Detail

      • FileService

        public FileService()
    • Method Detail

      • main

        public static void main​(String[] args)
      • appendTextToOneLine

        public static void appendTextToOneLine​(String filename,
                                               String textStr)
        Open the file for writing and write a text string.
        Parameters:
        filename - Output filename
        textArray - An array of strings
      • appendTextToOneLine

        public static void appendTextToOneLine​(String filename,
                                               String[] textArray)
        Open the file for writing and write textArray separated by a space to file all in one line.
        Parameters:
        filename - Output filename
        textArray - An array of strings
      • printStackTraceToFile

        public static void printStackTraceToFile​(String filename,
                                                 Exception exception)
        Print a stack trace to a text file.
        Parameters:
        filename - Output filename.
        exception - The exception to print stack trace of.
      • printDocumentToFile

        public static void printDocumentToFile​(String filename,
                                               Document docSource)
        Print a document to a text file.
        Parameters:
        filename - Output filename.
        docSource - The document (Document) to be printed
      • printDocumentToFile

        public static void printDocumentToFile​(String filename,
                                               DOMSource domSource)
        Print a document (DOMSource) to a text file.
        Parameters:
        filename - Output filename.
        domSource - The DOM source to be printed