Reputation: 147
I configured my properties file with my source path and dest path :
pathSource = C://Test
pathOut = C://Test//Folder
I try to copy this file from pathSource to pathOut (with variable config.getValue()
:
Files.copy(config.getValue("pathTemplate"), config.getValue("pathOut"), REPLACE_EXISTING);
My 2 variables config are String why I have this error : Cannot resolve method 'copy(java.lang.String, java.lang.String, java.nio.file.StandardCopyOption)
Upvotes: 1
Views: 164
Reputation: 1
Files.copy method does not accept String parameters. It accepts Path parameters. Please see the documentaion: https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html You will have to change your config.getValue to return a Path object or convert the String output into Path objects
Upvotes: 0
Reputation: 2282
Files.copy()
requires the first two parameters to be of type Path
.
You need to construct those from your strings i.e.
Path input = Paths.get(config.getValue("pathTemplate"));
Path output = Paths.get(config.getValue("pathOut"));
Files.copy(input, output, REPLACE_EXISTING);
Upvotes: 2