Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8663489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:59:48+00:00 2026-06-12T16:59:48+00:00

I try to use example from this question : How to copy a folder

  • 0

I try to use example from this question : How to copy a folder and all its subfolders and files into another folder

I made him static, and when I call copyDirectory(), I have an exception during program runs :

Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem: 
Unhandled exception type IOException

At every line that uses this method.

I added

  throws IOException 

for every method that uses copyDirectory()

Error’s count had been shorted, but they remained at native java classes. And I can’t edit them : it would be an infinite editing recursion :))

Advance I’m sorry for bad english.

UPD: (Using ApacheCommonsIO)

import org.apache.commons.io.FileUtils;
// the rest import
public class MyClass{
  public myMethod(){
   String src = "/home/user/dir_src";
   String dst = "/home/user/dir_dst";
   FileUtils.copyDirectory(new File(src), new File(dst)); 
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:59:49+00:00Added an answer on June 12, 2026 at 4:59 pm

    2 Things here

    1. You should format your method copyDirectory somehow like this, so it won’t throw you all these exceptions:
    
    
        public static boolean copyDirectory(File source, File destination) {
          try{
            // Copy Stuff
            return true;
          catch(IOException e){
            // Your way of ErrorLogging
            return false;
          }
        }
    
    
    1. For all the IO-Stuff like copying deleting and so on I would recommend you using ApachCommonIO: http://commons.apache.org/io/.

    Edit:

    Please try this code now, this should at least compile and give you a hint what is wrong:

    import org.apache.commons.io.FileUtils;
    // the rest import
    public class MyClass{
      public myMethod(){
       String src = "/home/user/dir_src";
       String dst = "/home/user/dir_dst";
       try{
          FileUtils.copyDirectory(new File(src), new File(dst)); 
       catch(IOException e){
          e.printStackTrac();
       }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to use doctest from example from http://docs.python.org/library/doctest.html But when I run python
From this excellent UTF-8 all the way through question, I read about this: Unfortunately,
In an attempt to build example code for this question, I ran into a
I try to use the client side validation on a very simple example and
i try to use TBXML and getting this error TBXML class method +tbXMLWithURL not
I try to use this: xml2struct when I use this xml: <XMLname attrib1=Some value>
My question is sort of a follow on from this question below but I
I hate to ask another how do you do this with regex question on
I try to use Pool from the multiprocessing module to speed up reading in
I am trying to use the ::: method (is this an operator method?) from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.