Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Write something to the next available line in a file

  1. #1
    Member
    Join Date
    Jan 2011
    Posts
    88
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Write something to the next available line in a file

    The title basically says. What I'm trying to do it to get the output of the my program to write to a text file (which i have working) but I want to to go a the next empty line every time the program is ran instead of over-writing what is already saved. Ived tried making a Scanner and using nextLine() but that apperently only works for handling input not writing to a text file. Any help would be appreciated!


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Write something to the next available line in a file

    How are you writing to the file? Which class are you using? Have you looked at what constructors that class has?
    Improving the world one idiot at a time!

  3. #3
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Write something to the next available line in a file

    Quote Originally Posted by frozen java View Post
    The title basically says. What I'm trying to do it to get the output of the my program to write to a text file (which i have working) but I want to to go a the next empty line every time the program is ran instead of over-writing what is already saved. Ived tried making a Scanner and using nextLine() but that apperently only works for handling input not writing to a text file. Any help would be appreciated!
    Read PrintWriter or FileWriter class if you are writing in a file using PrintWriter or FileWriter and see it's constructor's docs, you will for sure find the solution.

Similar Threads

  1. Java I/O File code; how to read/write file
    By ryu2le in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: September 18th, 2011, 05:51 PM
  2. Reading a file line by line using the Scanner class
    By JavaPF in forum File Input/Output Tutorials
    Replies: 0
    Last Post: April 17th, 2009, 07:34 AM
  3. Reading a file line by line using the Scanner class
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: April 17th, 2009, 07:34 AM
  4. How to Read a file line by line using BufferedReader?
    By JavaPF in forum File Input/Output Tutorials
    Replies: 0
    Last Post: May 19th, 2008, 06:32 AM
  5. How to Read a file line by line using BufferedReader?
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: May 19th, 2008, 06:32 AM