IFile to java.io.File [message #290664] |
Mon, 29 August 2005 14:41 |
Eclipse User |
|
|
|
Originally posted by: shane.infotec.com
Hi,
I was wondering if it's possible to convert a
org.eclipse.core.resources.IFile to a java.io.File. I want to parse the
file using javax.xml.parsers.DocumentBuilder, but the method public
Document parse(File f) takes in a java.io.File as a parameter.
Any thoughts?
Shane
|
|
|
|
|
Re: IFile to java.io.File [message #291100 is a reply to message #290666] |
Wed, 07 September 2005 19:50 |
Eclipse User |
|
|
|
Originally posted by: john.eclipsefaq.org
Simon Vaillancourt wrote:
> IFile f = (IFile)element.getUnderlyingResource();
> IPath path2 = f.getFullPath();
> File file = path2.toFile();
This snippet is wrong. The correct way to get a java.io.File from IFile is:
IFile f = ...;
IPath location = f.getLocation();
if (location != null)
java.io.File file = location.toFile()
The "full path" of a resource is not a file system path, but rather a
path in the workspace tree (relative to workspace root).
--
|
|
|
Powered by
FUDForum. Page generated in 0.02721 seconds