javaapache-commons-io

Trying to copy file from one location to another


I'm trying to copy a file to another directory with Commons' fileUtils. I tried this

FileUtils.copyFile(getOutputFile(), new File("RESULT/final_result.txt");

The new final_result.txt file contains only the first line of my output file, what did I do wrong?

Is there an alternative to Commons IO, or some other way I'll take any as long as it does the trick.


Solution

  • If you write the file (which you get by getOutputFile()) before this operation, be sure to flush() all changes.

    Otherwise it seems to be a bug. But it is unlikely.