Monday, September 28, 2009

Re: [Java] Path - Workspace

 

Have you tried hardcoding the path in your new File () statement?
File file = new File ("C:\\myWorkspace\\MyProject\\new.txt");

Or, make it a little more portable:
String dir = ... // Possibly get the value from a .properties file?
File file = new File (dir + "\\new.txt");

-Java Guy

pedrogabrielvecchi wrote:
>
>
> Hello:
>
> I use WID 6.1.2 Build id: 6.1.2ifix004-20090401_1943.
> When I do
>
> File file = new File("new.txt");
> String absolutePathOfFirstFile = file.getAbsolutePath();
> System.out.println("Folder: " + absolutePathOfFirstFile);
>
> or
>
> IWorkspace workspace = ResourcesPlugin.getWorkspace();
> String folder=
> workspace.getRoot().getLocation().toFile().getPath().toString();
> System.out.println("Folder: " + folder);
>
> The result is "C:\WID612\pf\wps", the folder where I install the WID
>
> How I get the name of the workspace folder with code java, for example
> "C:\myWorkspace\myProyect".?
>
> What I really need is to open the file new.properties in the folder
> "C:\myWorkspace\myProyect\Resources".
>
> Properties propiedades = new Properties();
>
> String locationFile = ??????
>
> FileInputStream propertiesFile = new FileInputStream(locationFile);
> properties.load(propertiesFile);
> String user = properties.getProperty("dataSource.username");
>
> Any idea?
>
> Thanks
>
>

__._,_.___
Visit http://aiaiai.com or http://jgame.org for more groups to join.
Java Official Group is created for the following topics: Java 2 Enterprise Edition - J2EE, Java 2 Standard Edition - J2SE, Java 2 Micro Edition - J2ME, XML, XSL, XSD, XPATH, Web Services, Jini, JXTA for all type of Java Geeks.
Whoever posts spam / ads / job related message will be BANNED IMMEDIATELY
Recent Activity
Visit Your Group
Yahoo! Finance

It's Now Personal

Guides, news,

advice & more.

Ads on Yahoo!

Learn more now.

Reach customers

searching for you.

Yahoo! Groups

Auto Enthusiast Zone

Auto Enthusiast Zone

Discover auto groups

.

__,_._,___

No comments:

Post a Comment