Results 1 to 3 of 3
  1. #1
    jessie is offline Member
    Join Date
    Nov 2010
    Posts
    29
    Rep Power
    0

    Default 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 all the text is not getting printed...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..

  2. #2
    Singing Boyo is offline Senior Member
    Join Date
    Mar 2009
    Posts
    552
    Rep Power
    6

    Default

    I'll respond to this one. Looks like the OP somehow had his thread double-post one after the other.
    If the above doesn't make sense to you, ignore it, but remember it - might be useful!
    And if you just randomly taught yourself to program, well... you're just like me!

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. Replies: 1
    Last Post: 02-27-2010, 02:29 AM
  2. writing to text file problem
    By blumdiggity in forum Networking
    Replies: 1
    Last Post: 02-26-2010, 03:43 PM
  3. writing to specific line in text file
    By mickmos in forum New To Java
    Replies: 2
    Last Post: 04-18-2009, 02:01 PM
  4. Writing To A Specific Text File Line
    By mokonji in forum New To Java
    Replies: 1
    Last Post: 03-02-2009, 09:13 PM
  5. writing text to file
    By notwist in forum New To Java
    Replies: 3
    Last Post: 04-25-2008, 05:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •