• Post Reply Bookmark Topic Watch Topic
  • New Topic

File(s) copying through JAVA APIs

 
siva krishnan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Are there APIs in JAVA to do the DOS equivalent of :
" copy ABC*.txt d:\myfiles\"
using built-in API in JAVA ?
(Trying to copy specific files to another Directory)
Thanks.
 
Gillian Bladen-Clark
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use something like:

You'd have to call this method in a loop going through all the files you want to copy. Perhaps someone else will know if there's a method that will call the operating systems own file copying method directly.
[ January 04, 2004: Message edited by: Gillian Bladen-Clark ]
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at this thread for a discussion and example using the java.io package.
Also look at the JavaAlmanac.com Example 172 Copying One File to Another for info on how to do it with java.nio ("New" IO package added in Java 1.4), or more specifically, using the java.nio.channels package.
[ January 04, 2004: Message edited by: Mark Vender ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the I/O and Streams forum...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!