I want to copy a file using spring FileCopyUtils. this is the first time I used I followed a tutorial and I get this exception
package com.sctrcd.multidsdemo.integration.repositories.foo;
import java.io.File;
import java.io.IOException;
import org.springframework.util.FileCopyUtils;
public class CopyTest {
public static void main(String[] args) throws InterruptedException,
IOException {
File source = new File("C:\\Users\\Momo Kh\\Desktop\\CV.pdf");
File dest = new File("C:\\Users\\Momo Kh\\Desktop\\Test\\CV.pdf");
FileCopyUtils.copy(source, dest);
}
}
And i have this Exception
Exception in thread "main" java.io.FileNotFoundException: C:\Users\Momo Kh\Desktop\CV.pdf (La syntaxe du nom de fichier, de répertoire ou de volume est incorrecte)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at org.springframework.util.FileCopyUtils.copy(FileCopyUtils.java:63)
at com.sctrcd.multidsdemo.integration.repositories.foo.CopyTest.main(CopyTest.java:15)
This code works (The same as the last with some change) I think it was a bug
package com.sctrcd.multidsdemo.integration.repositories.foo;
import java.io.File;
import java.io.IOException;
import org.springframework.util.FileCopyUtils;
public class CopyTest {
public static void main(String[] args) throws InterruptedException,
IOException {
File source = new File("C:\\Users\\Momo Kh\\Desktop\\CV.pdf");
File dest = new File("C:\\Users\\Momo Kh\\Desktop\\files\\destfile1.pdf");
long start = System.nanoTime();
long end;
// copy file using Spring FileCopyUtils
start = System.nanoTime();
FileCopyUtils.copy(source, dest);
end = System.nanoTime();
System.out.println("Time taken by Spring FileCopyUtils Copy = " + (end - start));
}
}
And the result
Time taken by Spring FileCopyUtils Copy = 41100377