kle*_*ite 2 smalltalk file save pharo
我目前正在通过Pharo MOOC学习 Pharo ,在讲座“3.8 流概述”中,我们展示了以下用于创建文件的流操作示例:
| stream |
stream := 'hello.txt' asFileReference writeStream.
stream nextPutAll: 'Hello Pharo!'.
stream close.
Run Code Online (Sandbox Code Playgroud)
我在操场上执行了这个代码片段,然后我查看了安装 Pharo 的文件夹,在 Ubuntu 20.04 中的 ~/src/pharolauncher 下,检查文件是否已创建,但它在文件夹或其子文件夹中没有任何位置。
You have a relative path and would like to convert it to absolute, right?
OK. The key part of your code is
'hello.txt' asFileReference
Run Code Online (Sandbox Code Playgroud)
If you inspect this object you will see its class is, not surprisingly, FileReference. Browse the class. Find some selector containing the word 'absolute' or 'Absolute'. The one that looks promising is #absolutePath. Give it a try.