Smalltalk:将输出写入文件
通常,我将输出写入到成绩单中...
Transcript show:
如何将输出写入文件?
Usually with my output I am writing it to the Transcript with...
Transcript show:
How does one write the output to a file instead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您想要使用 FileStream
请参阅此描述 FileStreams 的链接
摘录如下:
FileStream
FileStreams support all of ExternalStreams protocol. They can be created to read, write, readWrite or append from/to a file.
Creation:
以上是内部低级实例创建协议,使用起来有些政治不正确。为了可移植性,请使用伴随类 Filename 来创建 fileStreams:
You want to use a FileStream
See this link describing FileStreams
Excerpt below:
FileStream
FileStreams support all of ExternalStreams protocol. They can be created to read, write, readWrite or append from/to a file.
Creation:
The above was the internal low level instance creation protocol, which is somewhat politically incorrect to use. For portability, please use the companion class Filename to create fileStreams:
当然,如果您不编写二进制或默认编码,请不要忘记处理您想要的字符编码。在 Pharo/Squeak 中,将转换器设置为所需的 TextConverter 子类。
And then of course don't forget to handle the character encoding you want, if you're not writing binary or the default encoding. In Pharo/Squeak, set the converter to the needed TextConverter subclass.