IntelliJ Java IDE
The moose likes IDEs, Version Control and other tools and the fly likes How to modify a file in an Eclipse plugin? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Reply Bookmark "How to modify a file in an Eclipse plugin?" Watch "How to modify a file in an Eclipse plugin?" New topic
Author

How to modify a file in an Eclipse plugin?

Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11945
I decided to write a plugin for Eclipse and the functionality requires modifying an existing file (an instance of org.eclipse.core.resources.IFile), which I'm having trouble with. More accurately, I don't have a clue about how such a task should be done.
IFile defines a few methods for reading from, appending to, and deleting the file. Is it ok to first delete(...) and then append(...) an IFile reference?
Hyperlinks are also appreciated as I've found the official eclipse.org articles to be very superficial in nature.
Thanks.


Author of Test Driven (Manning Publications, 2007) [Blog] [HowToAskQuestionsOnJavaRanch]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11945
Ok. I apparently had missed IFile#setContents(...), which sounds like the right thing to do/call.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11945
Yep, it works. Forget that I asked
 
 
subject: How to modify a file in an Eclipse plugin?
 
Threads others viewed
Converting IFile to ISelection
Eclipse Plugin
Beginner: Very simple Plug in
Connecting to CVS Repository from an Eclipse Plugin
converting java.io.File to org.eclipse.core.resources.IFile
IntelliJ Java IDE