Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the present working directory using spring

Tags:

java

spring

This is the code to get the present working directory of a java application at runtime.

String currentWorkingDirectory = System.getProperty("user.dir")+System.getProperty("file.separator");

Is there any way by which this can be configured using the spring-context xml.

For ex:

<bean id="csvReportGenerator" class="some.path.CSVReportGenerator">  
<constructor-arg name="outputFileName" value="${currentWorkingDirectory}/${reportOutputFileGeneric}"/>
</bean>
like image 313
Saikat Avatar asked May 20 '13 09:05

Saikat


1 Answers

Yes, you can do it using Spring expressions. See section 6.4.1 of this article

<property name="userDir" value="#{ systemProperties['user.dir'] }"/>
<property name="fileSep" value="#{ systemProperties['file.separator'] }"/>
like image 154
sanbhat Avatar answered Sep 19 '22 23:09

sanbhat