Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Content format in a text file  RSS feed

 
vinodh kumar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can some one advice how to approach in java to format the content of a file as mentioned below.

Present:


Output:

 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know how to read lines of a file? Do you know how to write lines to a file?
The basic algorithm is this:
1) read ====
2) if there are no more lines available abort
3) read 4 lines
4) combine those 4 lines into one line
5) write that line
6) go to step 1

If you use a Scanner the reading and checking can be done using nextLine() and hasNextLine().
 
vinodh kumar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob.
Let me try based on your algorithm and will revert if any problem.


~Vinodh Kumar
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!