Results 1 to 4 of 4
  1. #1
    Alerhau's Avatar
    Alerhau is offline Senior Member
    Join Date
    Jun 2011
    Rep Power

    Default Multiple Rows In File Creation

    Hello people! When you are creating files via Java, I only know how I create a long, long, long row of text into a file. Instead of that, is there any possibility of make Java create files with multiple rows in? Tries so far: I have tried to use the "\n" but it does not work when I'm creating files! :(

    Sincerely Alerhau

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power


    it does not work
    Please explain what does not work.
    The "\n" character should end a line of text. For other files, you may need to use different characters to end a record.
    What program are you using to view the file after it is written? Is there a problem in all file viewing programs or just for some of them?

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power


    It'll be the viewer used.
    Notepad (the default windows txt file viewer) doesn't recognise "\n" by default.

    If your program is running on the same machine the file is being written to then use a PrintWriter and use printLine().
    Or, use System.getProperty("line.separator").

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power


    Notepad (the default windows txt file viewer) doesn't recognise "\n" by default.
    But interestingly (to me at least) if you copy the content from Notepad to Word and back, you get all your line breaks.

    I sometimes do that when I want to look at source code from a jar or zip, but don't feel like firing up NetBeans.


Similar Threads

  1. insert multiple rows in the table from List
    By Bulelakes in forum JDBC
    Replies: 2
    Last Post: 11-15-2010, 01:19 PM
  2. Highlighting Multiple Selected Rows
    By bigj in forum New To Java
    Replies: 2
    Last Post: 02-07-2010, 05:31 PM
  3. Replies: 1
    Last Post: 04-23-2009, 07:55 PM
  4. Multiple Process Creation in EJB3.0
    By sankarguru in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 03-25-2009, 05:26 AM
  5. How to get multiple rows from Stored Procedure
    By SRJ1957 in forum Advanced Java
    Replies: 0
    Last Post: 08-11-2008, 08:26 PM

Tags for this Thread

Posting Permissions

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