0

I need to write the the processed data to a particular path within the project folder. When i tried this I got access denied error. Also this code is giving me weblogic server path. not the eclipse project path

FileOutputStream out;
System.out.println(new File(".").getAbsolutePath());
out = new FileOutputStream(new File(".").getAbsolutePath());
workbook.write(out);
out.close();
System.out.println("write_demo.xlsx written successfully on disk.");

I want write the file to the following path:

project-folder/war/write_demo.xlsx

How do i do that?

Madhawa Priyashantha
  • 9,633
  • 7
  • 33
  • 60
coder
  • 149
  • 3
  • 4
  • 17

2 Answers2

0

I know that this question it's quite old but I thought it might still be useful.

// Assuming that eclipseProject is a IJavaProject
IProject prog = eclipseProject.getProject();

for(String key: prog.getPathVariableManager().getPathVariableNames())
    System.out.println(key);

The code above will print out the keys to a Map that contains several useful absolute paths. In my case, the output is:

PROJECT_LOC 
WORKSPACE_LOC 
ECLIPSE_HOME 
PARENT_LOC

So the code to get the absolute path of the project is:

prog.getPathVariableManager().getURIValue("PROJECT_LOC").getPath()

This code is going to work also (and especially) if the project is not actually located in the workspace but it's located elsewhere and it has been imported.

Hope that it can be useful :)

Sibola
  • 11
  • 1
-2
System.getProperty("user.dir");

This Can be used to get project path in eclipse

Deepak TS
  • 19
  • 3