0
'''use Jython'''

import shutil

print dir(shutil)

There is no, shutil.move, how does one move a file with Jython? and while we at it, how does one delete a file with Jython?

3 Answers 3

4

os.rename() to move, and os.unlink() to delete -- just like Python pre-shutil.

Sign up to request clarification or add additional context in comments.

1 Comment

Note that os.rename will be different to shutil.move if the destination is on a different filesystem. shutil falls back to a copy+delete in this situation, but rename will just fail.
1

If you need support for moving across filesystems, consider just copying CPython's shutil.py into your project. The Python License is flexible enough to allow this (even for commercial projects), as long as licensing and attribution information are retained.

1 Comment

Or copy shutil.py from Jython 2.5
0
f1 = File(filename_old)
f1.nameTo(File(filename_new))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.