Hello I'm trying to copy 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.
if you write 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.
first, it seems you forgot to close the parenthesis containing the method's arguments. second, are you sure getOutputFile() yields a complete file?
Try new File(Result,"final_result.txt");
Result should be of type File
and final_result.txt String
Perhaps you need to do a simple test using a debug or sleep:
You'll either find that your write is not complete (in step 3) and you'll need to flush/close the correct ouput stream, or you'll find that the copy is doing something weird (which is less likely).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.