-4
 child.move(source,target, REPLACE_EXISTING);

I am trying to move files(childs) to different directory. It says move is undefined for file type File. Why is it outputting this? If it can't be fixed, what other methods exist?

  • 2
    Try to put meaningful code. What is the type of child? what is File? what is the error ? – sanbhat Jun 13 '13 at 16:56
  • @moonwave99 no, this is no duplicate; since there is `Files` now, SO users should be "reeducated" as to anything file-related in Java :p – fge Jun 13 '13 at 16:59
  • 1
    @fge - the problem is, even though we all know J6 is EOL, in the real world you can't rely on being able to use J7. There are places that still use J5 ::sigh:: – Brian Roach Jun 13 '13 at 17:21

1 Answers1

2

Why is it outputting this?

Because File has no such method...

If it can't be fixed, what other methods exist?

On File there is .renameTo() (but it's broken -- returns a boolean, cannot cross filesystem boundaries), but use Java 7's Files.move() instead which has none of File's drawbacks.

fge
  • 119,121
  • 33
  • 254
  • 329