ADC Home > Reference Library > Technical Q&As > Legacy Documents > Java >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

Moving Files in Java


Q: How do I move a file from one directory to another? Do I have to use the Mac OS Toolbox?

A: As long as the files are on the same volume, you just need to use the java.io.File.renameTo() method. Using this call for files and directories works equally well, but due to some platform-specific runtime implementation differences, this is one of those things that falls into the write once, test multiple places, and tweak until done catagories. This call will fail if you try to move a file from one volume to another.

Moving to another volume is more difficult, since this actually involves copying the file, and there is no standard Java call to copy a file. You would need to create your own, and on the Mac this becomes more complicated because you must worry about resource forks and file types. For this, you would need to use JDirect, or possibly JConfig or Greg Guerin's MacBinary Toolkit.

[Feb 02 2000]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.