I have an IFile shows the absolute path as
/dynamic/WebContent/testing.html
I开发者_如何学Go want to make some changes in the above testing.html. It means I need to load the file, then need to modify it and then save it . What is the procedure to execute the above steps in eclipse plug-in development.
See IFile.getContents(), setContents() and create() methods.
Use getContents to read file into memory, modify it, then use setContents to write it out. That will keep your workspace in sync. If you try to convert to File and use standard Java file I/O, your workspace will be out of sync (requiring refresh) and you will be completely incompatible with other file storage systems used by Eclipse
If your file is local try :
import java.io.RandomAccessFile;
RandomAccessFile file = new RandomAccessFile("IFile".getLocation().toFile(), "rwd");
精彩评论