Copying file to different directory
How do you copy a file to a different directory?
File inputFile =new File("C:\\input\\input.txt");
File outputFile =new File("C:\\output\\output.txt");
FileUtils.copy(inputFile , outputFile );
the copy method in FileUtils doesn't work for me. I copies the file but the file is always empty.
I simply just want to read a file, then copy it to a different directory.
thanks
> How do you copy a file to a different directory?
>
> > File inputFile = new File("C:\\input\\input.txt");
> File outputFile = new
> File("C:\\output\\output.txt");
> FileUtils.copy(inputFile , outputFile );
>
>
> the copy method in FileUtils doesn't work for me. I
> copies the file but the file is always empty.
>
> I simply just want to read a file, then copy it to a
> different directory.
>
> thanks
Is this the FileUtils class in jakarta commons IO (http://jakarta.apache.org/commons/io/), or your own homemade class? If the former, it must work so I'd have to conclude that your input file is empty or does not exist, or that there is something else you're assuming incorrectly.
Edit: Nope, you're not using Jakarta Commons IO FileUtils - that class has a copyFile method, not a copy method. So your own homemade implementation is buggy.
I'd suggest you use the Commons IO version (see the link I posted in this reply above).
Message was edited by:
warnerja