is there a way to define path in a java program which will change in future

69
July 16, 2017, at 9:08 PM

I am trying to create a program in java which will read a file but the problem is that,the path where that file is located will change with time.Is there a way to define path in the form of a variable or any other solution.

Answer 1

The standard solutions to this kind of problem are:

  • Use a command line argument
  • Use an application-specific configuration or properties file.
  • Use the Java Preferences API
  • Use environment variables
  • Use system properties; e.g. -Dname=value

The best / most appropriate solution(s) will depend on the nature of your application, and the way it is configured and launched.

READ ALSO
Why float behaves differently between Python/PHP/Javascript and Java/C#

Why float behaves differently between Python/PHP/Javascript and Java/C#

After 10 years I'm (re)studying Java and I'm writing simple code in order to check syntax and verify simple behaviorsI was playing with number types and I don't understand why floats behave differently in Java (and also C# as I verified later) than Python...

89
What are free floater code? [on hold]

What are free floater code? [on hold]

which code can be considered free floaters ? I am java beginner and I want to know how can I figure out free floater code

99
Not able to set custom color in XSSFCell Apache POI

Not able to set custom color in XSSFCell Apache POI

I am trying to set some custom(from hexcode or rgb value) color to a xssfcellBut the color of the cell is becoming black even though I am giving some other color

62
Runtime error	time: 0.06 memory: 4386816 signal:-1

Runtime error time: 0.06 memory: 4386816 signal:-1

I got Runtime error time: 006 memory: 4386816 signal:-1 for the following code on ideone

70