I have a requirement where I need to read the ini file from the current java project but I am unable to retrieve the path dynamically. I tried System.getProperty("user.dir")
to fetch the path but it does not work. It works fine on local system but does not work on AWS
. This code is running on AWS Lambda
to handle the events on S3.
Asked
Active
Viewed 3,723 times
1

Mosam Mehta
- 1,658
- 6
- 25
- 34

Swapnil
- 159
- 1
- 11
2 Answers
1
Try reading the value of the LAMBDA_TASK_ROOT environment variable:
final String projectPath = System.getenv("LAMBDA_TASK_ROOT");

Leon
- 31,443
- 4
- 72
- 97
0
You should be able to just open it by referencing it in ./src/main/resources/myfile.ini
, assuming you have a maven style project.
Alternatively you can access it via the classpath
-
Yeah i figured that out. I added the files under the resource folder and accessing it using getClass().getClassLoader().getResourceAsStream(xyz.properties). And you can do it by adding the file/folder path as a resource in pom.xml if you explicitly want to include a file/folder in your class path. Thanks for your input. – – Swapnil Oct 28 '15 at 00:08