开发者

How to load an IFile and modify the same in eclipse plug-in development

开发者 https://www.devze.com 2023-02-28 12:47 出处:网络
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.

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");
0

精彩评论

暂无评论...
验证码 换一张
取 消