0

I am trying to make an exe that will move a file from one folder to another automatically.I am having a hard time trying to write the code the grabs the file from my desired location. Here is the code that I have so far.

public class Transfer {
     Path source = C:\Users\Name\Google Drive;
             Path newdir = C:\Users\Name\Desktop;
             Files.move(source, newdir.resolve(source.getFileName()), REPLACE_EXISTING);
}
4

2 回答 2

1

如果你有很多文件操作,你可以使用 Apache 的 FileUtils,它非常容易使用: http://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/FileUtils。 html

看看方法move*。

于 2013-04-24T06:17:17.243 回答
0

您可以尝试 mkyong.com 的文件操作解决方案:http ://www.mkyong.com/java/how-to-move-file-to-another-directory-in-java/

于 2013-04-24T04:59:54.210 回答