code: public static void copy( File fileOrDirectory, File toDir )
    {
      File copy = new File( toDir, fileOrDirectory.getName() );
      if( fileOrDirectory.isDirectory() )
      {
        //noinspection ResultOfMethodCallIgnored
        copy.mkdir();
        for( File child : fileOrDirectory.listFiles() )
        {
          copy( child, copy );
        }
      }
      else
      {
        //noinspection ResultOfMethodCallIgnored
        try( InputStream is = new BufferedInputStream( new FileInputStream( fileOrDirectory ) );
             OutputStream os = new BufferedOutputStream( new FileOutputStream( copy ) ) )
        {
          StreamUtil.copy( is, os );
        }
        catch( Exception e )
        {
          throw new RuntimeException( e );
        }
      }
    }
docs: Recursively copy a file or directory to a directory.