为啥我原样写出来的copy的返回值是ArrayList类型而是不是视频中的Boolean类型呢

来源:5-5 groovy文件处理详解(上)

LiYang9

2019-04-17

def copy(String sourcePath, String destationPath) {
try {
def desFile = new File(destationPath)
if (!desFile.exists()) {
desFile.createNewFile()
}
new File(sourcePath).withReader {
read ->
def lines = read.readLines()
desFile.withWriter { writer ->
lines.each { line ->
writer.append(line+’\n’)
}
}
}
} catch (Exception e) {
e.printStackTrace()
}
}

def result = copy(’…/…/…/…/HelloGroovy.iml’, ‘…/…/…/…/HelloGroovy2.iml’)
println result.class

写回答

1回答

qndroid

2019-04-19

你没写返回值吧,copy函数。

0
0

Gradle3.0自动化项目构建技术精讲+企业级案例实操

全面覆盖Gradle核心知识和高级用法,高级工程师必备技能!

877 学习 · 144 问题

查看课程