The next step is to create an IFile
resource for the .html
file (based on the name of the .minimark
file). Eclipse uses an IPath
object to represent a filename from the root of the workspace. An IPath
of /project/folder/file.txt
refers to the file.txt
file in a folder called folder
contained within the project called project
. The root path represents the IWorkspaceRoot
. Perform the following steps:
In the
processResource()
method ofMinimarkVisitor
, calculate the new filename, and use it to create anIFile
from the file's parentIContainer
:try { IFile file = (IFile) resource; String htmlName = file.getName().replace(".minimark", ".html"); IContainer container = file.getParent(); IFile htmlFile = container.getFile(new Path(htmlName));
To create the contents of the file, an
InputStream
has to be passed to thesetContents()
method. The easiest way to create this is to pass aByteArrayOutputStream
toMinimarkTranslator
, and then use aByteArrayInputStream...