Using FileUtils in eclipse
Asked Answered
F

7

27

When trying to use FileUtils I get "cannot be resolved" error.

enter image description here

Then, how do I install FileUtils library to be able to use it in Eclipse? I see it is an Ant utility, but I am not sure how many jars I need to install.

enter image description here

Fetterlock answered 31/10, 2012 at 19:44 Comment(0)
M
38

Open the project's properties---> Java Build Path ---> Libraries tab ---> Add External Jars

will allow you to add jars.

You need to download commonsIO from here.

Metritis answered 31/10, 2012 at 19:48 Comment(0)
T
9

Now selenium supports following code:

FileHandler.copy(src, dest);
Terle answered 10/5, 2018 at 11:6 Comment(0)
D
6
<!-- https://mvnrepository.com/artifact/org.apache.directory.studio/org.apache.commons.io -->
<dependency>
    <groupId>org.apache.directory.studio</groupId>
    <artifactId>org.apache.commons.io</artifactId>
    <version>2.4</version>
</dependency>

Add above dependency in pom.xml file

Dubiety answered 25/6, 2018 at 5:49 Comment(2)
An answer should explain what it is doing.Breen
Choose the latest version from here.Carlie
J
1

FileUtils is class from apache org.apache.commons.io package, you need to download org.apache.commons.io.jar and then configure that jar file in your class path.

Jayejaylene answered 24/1, 2015 at 5:11 Comment(0)
C
1

I have come accross the above issue. I have solved it as below. Its working fine for me.

  1. Download the 'org.apache.commons.io.jar' file on navigating to [org.apache.commons.io.FileUtils] [ http://www.java2s.com/Code/Jar/o/Downloadorgapachecommonsiojar.htm ]

  2. Extract the downloaded zip file to a specified folder.

  3. Update the project properties by using below navigation Right click on project>Select Properties>Select Java Build Path> Click Libraries tab>Click Add External Class Folder button>Select the folder where zip file is extracted for org.apache.commons.io.FileUtils.zip file.

  4. Now access the File Utils.

Calycine answered 28/3, 2018 at 20:41 Comment(0)
P
0

For selenium automation users

  1. Download Library file from http://www.java2s.com/Code/Jar/o/Downloadorgapachecommonsiojar.htm
  2. Extract
  3. Right click on the proj name from the explorer >> Build path >>Config Build Path
Patois answered 30/6, 2019 at 5:7 Comment(0)
L
-1

Instead of using FileUtils.copyfile(src,trg); use following in Selenium java FileHandler.copy(src, dest);

Lev answered 27/9, 2021 at 9:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.