I'm having some difficulty with reading a text file into a List object for my app. I've verified that the file exists, but as soon as I call the ReadList method, I get a java.io.IOException. I've tried several different ways to get there, but I keep coming up with the same results. Here's the basic B4A code I've got (taken from the tutorial):
I tried initializing the NerdWords object before calling the ReadList method, but no change.
I was afraid that it might be a permissions issue with trying to get the info from the DirAssets location, so I tried to copy the file to the DirInternal folder with the following:
With that code, I get the IOException on the File.Copy line. I've also tried all of this with a Map object, but I'm getting similar results. It seems like there's some issue getting the information from the DirAssets folder.
I even tried using a TextReader/Writer to "manually" copy the file line-by-line from the one in the Dir.Assets to a new file in DirInternal, but as soon as I tried to do anything with the file in DirAssets, it gives me the IOException. I'm still using the trial version as I get a feel for things, so I don't know if that has anything to do with it, but I'm kinda stuck right now until I figure this piece out. Any assistance would be greatly appreciated.
:sign0104:
EDIT: One thing I just thought of: Is there a size limit for the List object? The file is 1.4MB in size, and has about 168.5K lines of text.
B4X:
Dim NerdWords As List
NerdWords = File.ReadList(File.DirAssets, "nerd.txt")
Msgbox("Items in NerdWords = " & NerdWords.Size & CRLF & "Item #3 is: " & NerdWords.Get(2), "")
I was afraid that it might be a permissions issue with trying to get the info from the DirAssets location, so I tried to copy the file to the DirInternal folder with the following:
B4X:
If File.Exists(File.DirInternal, "nerd.txt") = False Then
File.Copy(File.DirAssets,"nerd.txt",File.DirInternal,"nerd.txt")
End If
I even tried using a TextReader/Writer to "manually" copy the file line-by-line from the one in the Dir.Assets to a new file in DirInternal, but as soon as I tried to do anything with the file in DirAssets, it gives me the IOException. I'm still using the trial version as I get a feel for things, so I don't know if that has anything to do with it, but I'm kinda stuck right now until I figure this piece out. Any assistance would be greatly appreciated.
:sign0104:
EDIT: One thing I just thought of: Is there a size limit for the List object? The file is 1.4MB in size, and has about 168.5K lines of text.
Last edited: