writing to file at a specified position
1 posts in topic
Flat View  Flat View

Posted By:   ravi_sambandam
Posted On:   Thursday, September 25, 2003 04:27 AM


This is my requirement.I need to open a file and write some data in specified format.
in the first line i need to write a string starting from the 10 character postion of that line.similarly i need to add more strings at specified position.how to do this.

ravi sambandam

Re: writing to file at a specified position

Posted By:   Stephen_McConnell  
Posted On:   Thursday, September 25, 2003 05:43 AM

I would use java.lang.StringBuffer to build the formatted string. Then use the java.io.File to get a handle to the file; and then use java.io.FileWriter to write the string out to your specific file.

You would loop through formatting and then writing your String to the file... When you are finished, close the FileWriter and exit...

Check out the JavaDocs (found on the Sun web site www.javasoft.com) for specifics on how to use those Classes.

If you have any more problems, the tutorials found on the Java Soft site also have specific code snippets to do about what you want... Any more problems, post what you have done so far (put code inbetween a

 set of tags) and we'll help.

Stephen McConnell

About | Sitemap | Contact