为啥我原样写出来的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函数。
00
相似问题