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

    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
    Location
    Eastern Florida
    Posts
    17,755
    Rep Power
    25

    Default

    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
    Posts
    12,165
    Rep Power
    20

    Default

    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
    Location
    Madgaon, Goa, India
    Posts
    11,453
    Rep Power
    20

    Default

    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.

    db

Similar Threads

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