• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in writing text line by line....

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have problem writing the data from "Source.txt" to Target.txt"
line by line. If i have about 10 lines in Source file , i am not able to write the text line by line into Target file. My following code writes all the contents of Source file into Target file in one line(but want it to be in different lines).
Any suggestions what i have to change in my code?

Thanks.

[This message has been edited by Jim Yingst (edited February 15, 2000).]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The method readLine() is reading in everything you need except the newline character - so all you really should need is to add back one newline character per line:
<code><pre> rafWrite.writeBytes(readFile + '\n');</pre></code>
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jim:
I had already tried adding a Newline character, it does'nt help me get the output in the different lines. If i add '\n', i get some special character(some black spot) at the end of each sentence, but the output is still in one single line.
Any further help!
Thanks for u'r reply.
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah yes - you're using Windows right? Windows expects \n\r to end each line. You can write this in a platform-independent way by accessing System.getProperty("line.separator"), or by using a BufferedWriter which has the method newLine().
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jim, it works fine with u'r solution. I tried both of them.
 
reply
    Bookmark Topic Watch Topic
  • New Topic