title: Java- Copy file to either new file or existing file
body: <p>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.</p>
  <p>If f2 is a directory I would like to copy f1 to this directory (the file name should stay the same).</p>
  <p>If f2 is a file I would like to copy the contents of f1 to the end of the file f2.</p>
  <p>So for example if F2 has the contents:</p>
  <blockquote>
  <p>2222222222222</p>
  </blockquote>
  <p>And F1 has the contents</p>
  <blockquote>
  <p>1111111111111</p>
  </blockquote>
  <p>And I do copy(f1,f2) then f2 should become</p>
  <blockquote>
  <p>2222222222222</p>
  <p>1111111111111</p>
  </blockquote>
  <p>Thanks!</p>