如何清除文本文件而不使用Groovy删除文本文件 [英] How to clear a text file without deleting it using groovy

查看:301
本文介绍了如何清除文本文件而不使用Groovy删除文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本文件,将使用它来写入内容..但是,每次向文件写入内容之前,我希望清除内容而不删除文件.

I've a text file which I'll be using it to write content.. But every time before I write something to the file, I wish to clear the content without deleting the file..

我将如何实现以上目标?有什么建议吗?

How would I achieve the above? Any suggestions?

推荐答案

使用文本文件,您只需将其设置为空字符串即可.

With text files you can simply set it to an empty string.

file.text = ''

这篇关于如何清除文本文件而不使用Groovy删除文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆