xxcopy single file copy in Java fails with double spaces in filename

Posted on 2009-04-16
Last Modified: 2012-06-21
I'm using xxcopy to do single file copies in a Java program.  All is well, unless the filename contains two consecutive spaces.

cmd /c xxcopy  "c:\source\folderx\file  name.doc" "c:\dest\foldery\"  /VL /C /H /K /YY /Q3

The code looks something like this, where sExec is the string above:
            Process p = Runtime.getRuntime().exec(sExec);
            iRtn = p.exitValue();

I'm outputting the exact value of "sExec", and then copying it into Start/Run.  It runs successfully from Start/Run.  Does anyone understand why this same command fails when run from a Java program?

Question by:jkavx
    LVL 92

    Accepted Solution

    try tyhis:

    exec(new String[] { "cmd", "/c", "xxcopy", "c:\source\folderx\file  name.doc" ,"c:\dest\foldery\" , "/VL", "/C", "/H", "/K", "/YY", "/Q3"});


    Author Closing Comment

    Thanks very much.  

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Suggested Solutions

    Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
    The viewer will learn how to implement Singleton Design Pattern in Java.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now