开发者

Cut a directory?

开发者 https://www.devze.com 2023-04-03 21:20 出处:网络
Is t开发者_JAVA技巧here a method to cut a directory/file in groovy instead of copyingto a new location and then deleting the original directory/file ?You mean move a file?

Is t开发者_JAVA技巧here a method to cut a directory/file in groovy instead of copyingto a new location and then deleting the original directory/file ?


You mean move a file?

You can do:

File file = new File( 'original.txt' )  
File dir = new File( 'destFolder' )  
boolean fileMoved = file.renameTo( new File( dir, file.getName() ) )  

Which uses the Java File.renameTo method

0

精彩评论

暂无评论...
验证码 换一张
取 消