code to copy and paste a folder from cd to a specified destination folder

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jacob varghese
    New Member
    • Jul 2010
    • 1

    code to copy and paste a folder from cd to a specified destination folder

    please give me code to do that.thanks in advance
  • Oralloy
    Recognized Expert Contributor
    • Jun 2010
    • 988

    #2
    Try googling "java execute system command", and you'll find many useful pages.

    Runtime.getRunt ime().exec("XCO PY /S D:\\*.* C:\\put\\it\\he re\\*.*");

    Comment

    • chaarmann
      Recognized Expert Contributor
      • Nov 2007
      • 785

      #3
      Use FileUtils().cop yDirectoryToDir ectory() from Jakarta Commons.

      Don't use a shell command for doing the copy as suggested above. XCOPY only works for MS-DOS (windows), but not for apple, unix, mobile phones etc.
      A great effort was done to make Java operating-system -independent, so don't cripple it!

      Comment

      • Oralloy
        Recognized Expert Contributor
        • Jun 2010
        • 988

        #4
        chaarmann,

        You are, indeed, right in regard to operating systems.

        Thanks.

        Comment

        Working...