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

  • Home
  • SEARCH
  • 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 857305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:22:44+00:00 2026-05-15T08:22:44+00:00

Is it possible to copy directory contents using the Java I/O and File-related APIs

  • 0

Is it possible to copy directory contents using the Java I/O and File-related APIs while preserving existing symlinks? I am working on a tool that needs to perform “directory copy” operations on a variety of UNIX flavours while preserving existing symlinks.

I’d prefer to attempt this using the core Java SE libraries without resorting Runtime.exec/ProcessBuilder to invoke the platform’s “/bin/cp” binary. Apache Commons’ IOUtils doesn’t appear to support this either.

My last resort will be to use Runtime.exec/ProcessBuilder!

UPDATE:
I guess I’ll be using Runtime.exec/ProcessBuilder to call out to the native “cp” executable since this doesn’t seem to be possible using the core Java APIs nor any of the Apache Commons libraries.

  • 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-05-15T08:22:45+00:00Added an answer on May 15, 2026 at 8:22 am

    Are you restricted to Java versions <= 6?

    Otherwise you may want to look at http://docs.oracle.com/javase/tutorial/essential/io/links.html, specifically the sections Detecting a Symbolic Link and Finding the Target of a Link.

    From The Java NIO.2 File System in JDK 7:

    The java.nio.file API has full support for symbolic links based on the long-standing semantics of UNIX symbolic links — something that Java developers have long requested.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Best way to copy the entire contents of a directory in C#
Possible Duplicate: Copy Constructor is not invoked # include <iostream> using namespace std; class
Is it possible to show the working copy when doing searches in TortoiseHG? I've
Possible Duplicate: Copy to Output Directory copies folder structure but only want to copy
Possible Duplicate: Copy to Output Directory copies folder structure but only want to copy
Is it possible to copy a new file created by third party application inside
I am using boost::filesystem to copy a directory recursively. I would like to exclude
Possible Duplicate: Visual Studio Post Build Event - Copy to Relative Directory Location i
It´s possible to use two urls with File.Copy with C#? I´m getting different errors
Is it possible to manage files and directories (i.e. get a directory's content, create/copy/delete

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.