groovy – process.text的错误等价物?

groovy – process.text的错误等价物?,第1张

概述You can get the entire output stream使用.text: def process = "ls -l".execute()println "Found text ${process.text}" 是否有一个简洁的等价物来获取错误流? 你可以使用waitForProcessOutput,它有两个Appendables( docs here) def process = You can get the entire output stream使用.text:

def process = "ls -l".execute()println "Found text ${process.text}"

是否有一个简洁的等价物来获取错误流?

解决方法 你可以使用waitForProcessOutput,它有两个Appendables( docs here)

def process = "ls -l".execute()def (output,error) = new StringWriter().with { o -> // For the output  new StringWriter().with { e ->                     // For the error stream    process.waitForProcessOutput( o,e )    [ o,e ]*.toString()                             // Return them both  }}// And print them out...println "OUT: $output"println "ERR: $error"
总结

以上是内存溢出为你收集整理的groovy – process.text的错误等价物?全部内容,希望文章能够帮你解决groovy – process.text的错误等价物?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1234710.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-06
下一篇2022-06-06

发表评论

登录后才能评论

评论列表(0条)

    保存