文件复制

2015-12-14 0 939
文件复制
import java.io.*

if (args.size() != 2)  
    println ">>>>>>"
else {
    def outFile = new File(args[1])
    if(outFile.exists()) {
        def ans 
        System.in.withReader {
            print "File ${args[1]} is already there, you wanna to overwrite it?(y/n) "
            ans = it.readLine()
            println "You choose >> $ans <<"
            if(it =~ /n|N/ ) { 
                println "Exit without changing anything..."
                return
            }   
        }   
    
    }   

    def printWriter = outFile.newPrintWriter()

    new File(args[0]).eachLine { line ->
        printWriter.println(line)
    }   

    printWriter.flush()
    printWriter.close()
}

遇见资源网 groovy 文件复制 http://www.ox520.com/13725.html

上一篇:

已经没有上一篇了!

下一篇:

已经没有下一篇了!

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务