常规读取文件A并将特定行输出到文件B [英] groovy read file A and output specific lines to file B
本文介绍了常规读取文件A并将特定行输出到文件B的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以给我一个使用filterLine或其他方法/机制来读取文件A中以abc开头的所有行并将这些行写入文件B的示例.谢谢.
Can someone give me an example of using filterLine or some other method/mechanism to read all lines in file A that begin with abc and write those lines to file B. Thanks.
推荐答案
以下是针对您的问题的一线解决方案:
Here's a one line solution for your problem:
new File("b.txt") << new File("a.txt").filterLine { it =~ /^abc/ }
这篇关于常规读取文件A并将特定行输出到文件B的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文