Results 1 to 7 of 7
  1. #1
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default printWriter problem

    I finished the program, but still 2 things I don't understand.
    First, he doesn't want to write something in file output2b, but he does print it on the screen if I ask so. So the path works, but he just doesn't write to the file. But the other file where he found a hit (output1b) there he does write it in the file. But there he stops when he is almost finished. And I don't know why? But at the same time he does print everything on the screen if asked. So he did look at the whole file, but he just doesn't print everything.

    Java Code:
     
    xD
    Last edited by Lund01; 10-14-2010 at 01:15 PM. Reason: Keeping my code a little more for myself. :)

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default

    Read the API Doc
    PrintWriter(String fileName)
    Creates a new PrintWriter, without automatic line flushing, with the specified file name.
    So you have to call flush() after your println (or close() at the end :rolleyes: )

  3. #3
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    Never hears of flush() but I love him.
    Thanks. :)
    Works for the full 100%.

    Finally a programm I made that is gonna be used in the workfield and one that works for the full 100%. :D

    You don't know how happy I am right now!
    Also Norm thanks. :)

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    That's much better. :) I know what you really feel, I've the same experience a long time ago.

    One more hint. You've coded everything in a single method, main method. Are you aware about methods? If so try to implement the same with different methods. So you can learn basis about object oriented concepts without an effort.

  5. #5
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    That's much better. :) I know what you really feel, I've the same experience a long time ago.

    One more hint. You've coded everything in a single method, main method. Are you aware about methods? If so try to implement the same with different methods. So you can learn basis about object oriented concepts without an effort.
    Thanks.
    I know how that works in Python, but I will look it up for Java.
    Java gets addicted, now I realy love programming.
    I had never so much fun with Python as i have with java. :D

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    So then good luck. Welcome to Java World. I'm sure you've lots of fun sooner with Java, and also with our forum.

  7. #7
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

Similar Threads

  1. Help with printwriter class
    By eel in forum New To Java
    Replies: 9
    Last Post: 09-19-2010, 02:04 PM
  2. Help with PrintWriter code
    By eel in forum New To Java
    Replies: 4
    Last Post: 09-19-2010, 07:36 AM
  3. Help with printwriter.
    By Addez in forum New To Java
    Replies: 2
    Last Post: 10-30-2009, 01:58 PM
  4. difference printwriter & out.println
    By tushar88 in forum Java Servlet
    Replies: 1
    Last Post: 03-10-2009, 05:15 AM
  5. Using Printwriter (java.io.*)
    By LifeWithJava in forum New To Java
    Replies: 3
    Last Post: 12-25-2008, 08:07 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
  •