This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques and have Mario Casciaro & Luciano Mammino on-line!
See this thread for details.
Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Exception in System (Runtime) execute command for copying the file

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can any one tell me what is wrong with this - it throws an IOException

String sourcepath = "C:"+File.separator+"pbx"+File.separator+"mantra"+File.separator+"vvvvv.mp3";
String destinationpath = "C:"+File.separator+"rrr"+File.separator+"mantra"+File.separator+"mantra.mp3";
Runtime rt=Runtime.getRuntime();
try{
String command="C:"+File.separator+"windows"+File.separator+"command /c copy "+sourcepath+" "+destinationpath;
System.out.println(command);
rt.exec(command);
}catch(IOException ex){System.out.println("exception "+ex); ex.printStackTrace();}

output:-
C:\windows\command /c copy C:\pbx\mantra\vvvvv.mp3 C:\rrr\mantra\mantra.mp3
exception java.io.IOException: CreateProcess: C:\windows\command /c copy C:\pbx\mantra\vvvvv.mp3 C:\
rrr\mantra\mantra.mp3 error=2
java.io.IOException: CreateProcess: C:\windows\command /c copy C:\pbx\mantra\vvvvv.mp3 C:\rrr\mantra
\mantra.mp3 error=2
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Win32Process.java:66)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at java.lang.Runtime.exec(Runtime.java:428)
at java.lang.Runtime.exec(Runtime.java:364)
at java.lang.Runtime.exec(Runtime.java:326)
at Test.main(Test.java:82)
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
instead of command, did you try with "cmd /c copy" ?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and check this out:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
 
ranch ravi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
not find the solution. plz help..
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"ranch ranch",

Welcome to the Ranch.

We're a friendly bunch, but we take display names seriously. Display names must two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile since accounts with invalid display names get deleted.

thanks,
Dave.
 
What does a metric clock look like? I bet it is nothing like this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic