Hey,
I have tried (and sadly failed) to print out the content from a text file into a new Microsoft Word document.
Below is the code from my attempt. Also, I can't download any other additional libraries other than the usual ones.
Microsoft Word won't open up the file as it can't read the contents and says it's corrupt.
public static void exportMS() throws IOException { File exp = new File("Menu.docx"); File cou = new File("Courses.txt"); PrintWriter pw = new PrintWriter(new FileWriter(exp)); BufferedReader brC = new BufferedReader(new FileReader(cou)); while (brC.readLine() != null) { pw.println(brC.readLine()); } brC.close(); pw.close(); }
Also, is it possible to append other text files to the same MS Word document?
Thank you!