Content in text file to MS Word file help!
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.
Code :
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!
Re: Content in text file to MS Word file help!
Word documents are not just text, they are a particular file format containing all sorts of other important information such as formatting. You will need a 3rd party library - such as Apache POI - to get the actual text of the document, append, and rewrite the file.
Re: Content in text file to MS Word file help!
I have only one question here :) Why can't you download/use other libraries?
application context
Re: Content in text file to MS Word file help!
I can't download libraries, because the guidelines for my dossier say I can't.