Hi Guys, I need to write a JAVA program that copies all text files in a Directory to another Directory. I tried using runtime.exec(cmd /c copy *.txt ../newdir) But it is working erratically...some times it copies..but some times it doesn't.....are there JAVA API's which can do this ? Thanks in Advance.
There aren't any Java APIs to the OS copy command. You can write the copy operations yourself. Create a File object with the directory name, use the list() method to find all the files in the directory, for each text file create another pair of File objects for copy source and copy destination, read bytes from source and write bytes to destination. Is that enough to go on?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi