0

I want to get the file location paths using properties file for below case.

FileInputStream file = 
 new FileInputStream(new File("D:\\Source folder\\sourcefile.xlsx"));

FileOutputStream outputStream = 
 new FileOutputStream("D:\\Destination folder\\destfile.xlsx")

Note: I will be placing the properties file outside the jar file which could be edited by the user.

Thanks in advance!!

Sanjeev
  • 9,876
  • 2
  • 22
  • 33
Prabhu
  • 117
  • 1
  • 3
  • 11

1 Answers1

0

Take a look at the ResourceBundle class in Java SE 7 https://docs.oracle.com/javase/7/docs/api/java/util/ResourceBundle.html

You should be able to make statements like

destinationpath = D:\Destination folder\destfile.xlsx

inside a .properties file you place inside your Server Start classpath and load them by simply specifying the location in the classpath.

For example, if you place your 'application.properties' file in WEB-INF/classes/resources, you can access the property like this:

ResourceBundle resourceBundle = ResourceBundle.getBundle("resources.application");
String destination = resourceBundle.getString("destinationpath")