How to copy file in java

后端 未结 6 1904
后悔当初
后悔当初 2021-02-13 18:56

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

6条回答
  •  灰色年华
    2021-02-13 19:55

    Is there a way i can fix this or a better way to copy the files?

    If you have the option, I would recommend you to go with Java version 7, and use the Path.copyTo method.

    Copy the file located by this path to a target location. [...]

    Otherwise I would recommend at least using the NIO packages and FileChannels.

提交回复
热议问题