Writing a long string to a text file
Hi,
im writing a huge string into a text file in my java program...the full text is getting printed in the system.out.println() statement.... but full text is not getting printed in the text file...only the last line is getting printed...can sumbdy tell me why is this and can you give me a solution? this is my code snippet..
List<ArrayList<? extends HasWord>> sentences = tagger.tokenizeText(new BufferedReader(new FileReader("D:/out.txt")));
for (ArrayList<? extends HasWord> sentence : sentences) {
ArrayList<TaggedWord> tSentence = tagger.tagSentence(sentence);
String outnew = Sentence.listToString(tSentence, false);
System.out.println(outnew);
try{
// Create file
FileWriter fstream = new FileWriter("D:/outnew.txt");
BufferedWriter out = new BufferedWriter(fstream);
out.write(outnew);
//Close the output stream
out.flush();
out.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
jessie..