Turns out it's very simple, just f contents
. For any future reference to check for already existing methods for an object in io you can use protos, e.g. f protos
Reading in a file in io programming language
-
06-08-2022 - |
Question
I'm looking to read in a simple text file using the IO language and print it to the screen, so far I have:
f := File with("test.txt")
f openForReading
but just have no idea how to print it or clone the contents to an object. If anyone knows anything or could point me in a good direction it would be much appreciated.
Solution
OTHER TIPS
Use readLine
to read one line to a string, and println
to print.
f := File with(fileName)
f openForReading
l := f readLine
l println
Create a File object with your specified path:
fileName := "yourFileName.txt"
file := File with(fileName)
Open and read the file into a variable
file open
fileText := file readToEnd
Then close the file.
file close
You should then have the 'fileText' variable available for use.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow