Spring how to create bean with constructor that contains a variable

185 Views Asked by At

I have the following object which I want to replace with a bean:

file = new File( filePath + fileName.substring(fileName.lastIndexOf("\\")+1)) ;

I tried:

<bean id="fileone" class="java.io.File">
<constructor-arg type="String" value="filePath + fileName.substring( fileName.lastIndexOf(&quot;\\&quot;)+1)"/>
</bean>

With the eventual goal of having this line of code:

file=fileone

However I get error:

java.io.FileNotFoundException: filePath + fileName.substring(fileName.lastIndexOf("\")+1) 

What is the reason for this error? In what way do I modify the bean?

0

There are 0 best solutions below