读取文件内容
groovy读取文件很方便,可以像这样读取文件内容到字符串中:
String fileContents = new File('/path/to/file').text
如果需要指定字符编码的话,可以这样:
String fileContents = new File('/path/to/file').getText('UTF-8')
groovy读取文件很方便,可以像这样读取文件内容到字符串中:
String fileContents = new File('/path/to/file').text
如果需要指定字符编码的话,可以这样:
String fileContents = new File('/path/to/file').getText('UTF-8')