Is there a way in Java to copy the contents of one directory to another. I've tried the listFiles() method and I can capture the contents of a directory, however, I can't seem to find a way to write the contents to another directory. Thanks, [ January 13, 2002: Message edited by: Donald Nunn ]
<b>Donald Nunn</b><br />Sun Certified Programmer for the Java 2 Platform
AFAIK there is no single method to copy a file, let alone a directory. To copy a file, you can either use File or RandomAccessFile, copying the contents from one instance to another. For File, you can use streams. For RandomAccessFile, you can use read() and write(). I suspect RandomAccessFile may be faster, as it is lower-level.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
You are going to have to go through the directory recursively and get a name for each file/directory. Then you will have to lock a FileInputStream onto each with its acoompanying Reader and create any directories the file requires. Then use a FileOutputStream and its appropriate writer to write the files. HTH,
Jason R. Kretzer<br />Software Engineer<br />System Administrator<br /><a href="http://alia.iwarp.com" target="_blank" rel="nofollow">http://alia.iwarp.com</a>
Why does your bag say "bombs"? The reason I ask is that my bag says "tiny ads" and it has stuff like this: