Me n My Programming

If Only I Have TIme

Marama Code 115 ~ How to convert String to Path

I normally create my path using string. It is simple and easy to manipulate. But sometimes there are functions that you want to use (from the internet) that uses IPath/Path as the type. So how do you convert your String path to IPath/Path? This is what I found:

import org.eclipse.core.runtime.Path;

String testModelProject = “X:\ExampleEUCTest”;
Path testModelProjectPath = new Path(testModelProject);

Simple and now you can use your path. Like:

IFile file= ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(testModelProjectPath); // get the file

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Information

This entry was posted on November 16, 2010 by in Java, Life on Marama.
%d bloggers like this: