File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Content format in a text file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Content format in a text file" Watch "Content format in a text file" New topic
Author

Content format in a text file

vinodh kumar
Ranch Hand

Joined: Jan 07, 2008
Posts: 41
Hi,

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

Present:


Output:



VINODH KUMAR
/**SCJP 1.5***chemical engineering rocks*/ [My Wiki]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19557
    
  16

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().


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
vinodh kumar
Ranch Hand

Joined: Jan 07, 2008
Posts: 41
Thanks Rob.
Let me try based on your algorithm and will revert if any problem.


~Vinodh Kumar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Content format in a text file
 
Similar Threads
Need to understand about threading issues?
Help needed in executing the DTSRUN command in java code
No JNDI name found in EJB
550 Invalid recipient Problem whilst I am sending Email using SMTP
can not deploy application!!!!