Skip to main content



      Home
Home » Newcomers » Newcomers » Reading file in one project from another project(Reading file in one project from another project)
icon5.gif  Reading file in one project from another project [message #1117482] Thu, 26 September 2013 09:51 Go to next message
Eclipse UserFriend
Hi all,
I have a file "sample.txt" at ProjectA-> src-> package->sample.txt
I want to access it from ProjectB-> src -> packageB-> Some.java class

How Do I give the RELATIVE PATH in ECLIPSE ??

Can anyone help me ?
Thanks in advance Smile
Re: Reading file in one project from another project [message #1117508 is a reply to message #1117482] Thu, 26 September 2013 10:14 Go to previous messageGo to next message
Eclipse UserFriend
On 9/26/2013 7:51 AM, Arshad Adavani wrote:
> Hi all,
> I have a file "sample.txt" at ProjectA-> src-> package->sample.txt
> I want to access it from ProjectB-> src -> packageB-> Some.java class
>
> How Do I give the RELATIVE PATH in ECLIPSE ??
>
> Can anyone help me ?
> Thanks in advance :)

There really isn't a way, especially a portable way, to do that.
Projects are a little like mini-universes outside of which nothing exists.
Re: Reading file in one project from another project [message #1117627 is a reply to message #1117508] Thu, 26 September 2013 12:43 Go to previous messageGo to next message
Eclipse UserFriend
Are you trying to access the file in a Java program? If so, then you can make Project B depend on Project A. The Project A source folder will then be added to the classpath of Project B and you can use the Class.getResource method to access the file.
icon5.gif  Re: Reading file in one project from another project [message #1117675 is a reply to message #1117627] Thu, 26 September 2013 13:41 Go to previous message
Eclipse UserFriend
Hello,
I can't add the project dependency because it will result in some other errors for me.
ok i will explain it correctly now.
I have one xtend file in ProjectA.
And I have a text file in ProjectB.
I want to write a method in xten file of ProjectA which will write some string to the text file Present in ProjectB.

In java I wrote:

public class FileHelper {

public void writeFileObject(final String append) {
File file = null;
file = new File("../ProjectB/resources/Sample.txt");
try {
FileWriter fw = new FileWriter(file, true);
fw.write(append);
fw.close();
} catch (IOException e) {
e.printStackTrace();
}

}
}

This works fine if I call writeFileObject method from main method or from a different java class. But if I call this method from that xtend file, its not working.
Please someone help!!!!!!

Thanks in advance Smile
Previous Topic:context sensitive shortcut key in Mac OS Eclipse
Next Topic:Keyboard - curved brackets?
Goto Forum:
  


Current Time: Fri Sep 26 16:34:09 EDT 2025

Powered by FUDForum. Page generated in 0.07696 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top