Reputation: 627
I downloaded apache commons FileUtils to perform a copy directory and added them under libraries in eclipse as well. When I say Fileutils.copyDirectory(s,d)
as give below eclipse says " Multiple markers at this line -Syntax error on token "(", delete this token
-Syntax error on token ")", delete this token". Can someone help
import org.apache.commons.io.FileUtils;
Public class b {
File s = new file("C://Tom//eso");
File d = new file("C://Tom//pos");
FileUtils.copyDirectory(s,d);
}
Upvotes: 1
Views: 1752
Reputation: 347314
You're trying to call a method outside of the body of a method...try something more along the lines of;
public class b {
public static void main(String args[]) {
File s = new File("C:/Tom/eso");
File d = new File("C:/Tom/pos");
try {
FileUtils.copyDirectory(s,d);
} catch (IOException exp) {
exp.printStackTrace();
}
}
}
Just to highlight...
Public
should be public
file
should be File
//
should be either /
or \\
(most people prefer /
)I'd also recommend that you take the time to learn the Java naming conventions as well as have a read through the tutorials under the Trails Covering the Basics section
Upvotes: 1
Reputation: 236124
Try this:
import org.apache.commons.io.FileUtils;
public class B {
public static void main(String[] args) throws Exception {
File s = new File("C:/Tom/eso");
File d = new File("C:/Tom/pos");
FileUtils.copyDirectory(s,d);
}
}
There are several errors in your code:
File
, not file
. And it's class B
, not class b
(remember to also rename the file to B.java
)/
chars, just onepublic
, not Public
Upvotes: 4
Reputation: 432
Two errors.
First
File s = new file("C://Tom//eso");
File d = new file("C://Tom//pos");
should be
File s = new File("C://Tom//eso");
File d = new File("C://Tom//pos");
Second
FileUtils.copyDirectory(s,d);
should in main method.
Upvotes: 0
Reputation: 51030
File s = new file("C://Tom//eso");
File d = new file("C://Tom//pos");
file
should be capitalized. It should be new File(...
.
Side note: Usually for windows the path looks like C:\\Tom\\eso
, you have forward-slashes instead of backward.
Upvotes: 1