Java- Copy file to either new file or existing file.

Posted by jared on Stack Overflow See other posts from Stack Overflow or by jared
Published on 2009-05-29T17:30:20Z Indexed on 2010/04/20 16:13 UTC
Read the original article Hit count: 215

Filed under:
|
|

Hi- I would like to write a function copy(File f1, File f2) f1 is always a file. f2 is either a file or a directory.

If f2 is a directory I would like to copy f1 to this directory (the file name should stay the same).

If f2 is a file I would like to copy the contents of f1 to the end of the file f2.

So for example if F2 has the contents:

2222222222222

And F1 has the contents

1111111111111

And I do copy(f1,f2) then f2 should become

2222222222222

1111111111111

Thanks!

© Stack Overflow or respective owner

Related posts about java

Related posts about file