Im trying to copy a file in java and move it to a new folder. This is the code i HAve been using but I always get this error \"(Access is denied) in the specified directory\". I
If you get this exception the access is really denied, i.e. you just do not have rights to write to the specified directory or file. So, first check it. Try for example to create the file in specified directory manually. Do you probably try to create file in somebody else' home directory? Or your java program is running as other user? What about foldertest2? Does it exist and writable? Try to copy your file there.
And the final tip. When you manage to copy the file, I'd recommend you to use IOUtils.copy()
(from jacarta commons). I use it a lot. It does almost exactly what you implemented but have to write of code one line only.