Reputation: 1600
I am trying to refactor a Spring Boot application where a hard coded CSV file name is to be replaced with a file name drawn from the "application.properties" file, like...
outputRoleCsv("d:\\temp\\lean-actor-role.csv",aModel.getActorRoles());
The property in the properties file is set to...
file.name.actor.role="d:\\temp\\lean-actor-role.csv"
However, when I replace the hard coded file name with the property derived value I get an error
java.io.FileNotFoundException: "d:\ emp\lean-actor-role.csv" (The filename, directory name, or volume label syntax is incorrect)
at java.base/java.io.FileOutputStream.open0(Native Method)
at java.base/java.io.FileOutputStream.open(FileOutputStream.java:298)
at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:237)
at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:187)
This has obviously something to do with the '\' chars, but I can't find a way of setting the application.properties value
Suggestions?
Upvotes: 1
Views: 3240
Reputation: 2744
You do not need dowble quotes in property files. Remove the double quotes and it will work.
file.name.actor.role=d:\\temp\\lean-actor-role.csv
Upvotes: 1