Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Brayden Smith   on Feb 04 In Java Category.

  
Question Answered By: Reginald Thomas   on Feb 04

You can write  a batch (.bat on Windows OS) or shell script (.sh on Linux OS) file
which performs the exact copy.
for example in Windows you can have "copy.bat" with this contents:

copy "%1" "%2"

and then you can call  

exec("PATH_TO_COPY_BAT/copy.bat d:/music/someFile.txt d:/downloads");

Alternatively you can do it with java. Read the contents of the file  with BufferedReader and write it to a newly created file with BufferedWriter. Use buffer to improve the performance:

bytes buffer = new byte[BUFFER_SIZE];
...
while (reader.read(buffer) != -1)
writer.write(buffer);
...

Share: 

 

This Question has 4 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on copy with command prompt Or get search suggestion and latest updates.


Tagged: