Link to home
Create AccountLog in
Avatar of satmisha
satmishaFlag for India

asked on

what is the way to get get path dynamically as I am getting Getting while using FileStream

Hi Experts,

I am trying to read text file which works great on my local but when I deploy it on server it creates problem because the path on server is different as that of my local.

My Local Path:
Server Path:

So in code I have used like this: +  new FileInputStream("./Project/File.txt")

It works great on my local but fails when I deploy it on server, reason is path.

Is there any way I could make it dynamic so that it could itself detect the right path ?

Looking forward to hearing from you.
Avatar of mccarl
Flag of Australia image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
You could also use a system property for the path and specify it on the command line
java -Dmypath=C:\Folder1\Project\ MyProgram

Or pass in the path as an argument to your program.
java MyProgram C:\Folder1\Project\ MyProgram
Avatar of satmisha


Apologies for late response. Thanks a lot for your help.
You're welcome!