1

I'm using this code in order to read a file content in a Maven module. The file is stored in one directory up to the working directory.

String configFilePath = System.getProperty("user.dir") + "../conf/gce-configuration.xml";

File configFile = new File(configFilePath);

Then when I try to read file it gives me file not found error.

file cannot be found : /home/xxxx/bin../conf/gce-configuration.xml

I tried different ways but still I'm getting this error. What I'm doing wrong here?

Edit: It seems like I forgot to mention the file name in assembly/bin.xml in maven module. So the xml file does not include to package. My bad!

Asanka sanjaya
  • 1,461
  • 3
  • 17
  • 35

1 Answers1

5

As you want to go one level above the current dir you can do that by

 String configFilePath = new File(System.getProperty("user.dir")).getParent() + "/conf/gce-configuration.xml";
Madhan
  • 5,750
  • 4
  • 28
  • 61