Reputation: 45
I recently started working on corona sdk and am trying to read a file and print it line by line. I searched for codes everywhere but they didn't work... It's important as I'm on an internship and need to get it done as soon as possible.
Here's the code that I used:
local path = system.pathForFile( "Level File Structure.txt", system. ResourceDirectory )
local file = io.open( path, "r" )
for line in file:lines() do
print( line )
end
io.close( file )
Upvotes: 0
Views: 2167
Reputation: 665
This should work provided the file exists and the path is correct;
local path = "Level File Structure.txt", system.ResourceDirectory
local function printWords()
local file = io.open(path, "r")
for lines in file:lines() do
print (lines)
end
io.close(file)
end
printWords()
Upvotes: 2