This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes writing data at a particular postion in a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "writing data at a particular postion in a file" Watch "writing data at a particular postion in a file" New topic
Author

writing data at a particular postion in a file

Sayali Basole
Greenhorn

Joined: Mar 15, 2013
Posts: 1


I want to write a data in a .java file at a particular position.. I have tried with randaomAccessfile but it is not working. please give some proper suggestion
Thanks in advance
James X Peterson
Whizlabs Java Support
Ranch Hand

Joined: Feb 26, 2013
Posts: 158
Hi Sayali Basole,

first read complete java file in to a string and then by using conditions get the position where you want to write the data. write the data at that position and write the modified string in to the file.


Regards,
James
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2724
    
  56
Welcome to the Ranch,

Please TellTheDetails (← click) just saying it doesn't work doesn't make it easy for anyone to help you. Please explain what you have tried, what you expected to happen, what actually happened and post a SSCCE .
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: writing data at a particular postion in a file
 
It's not a secret anymore!