Android Question [SOLVED] File.readlist, first item is empty


Licensed User

I'm trying to read a file using the file.readlist() method. For some reason the first item in the list is empty, although there is no CR of LF at the beginning.

Attached is the file in question, and here is the hex view of the first bytes:


Any ideas why?


    710 bytes · Views: 89


Licensed User
The files are created in another language (Xojo on PC). They contain the description of a SQLite database that B4A reads and then uses to create the db.

Only three lines in it:

First line:
<Database>FYTO_Alain.sq3</Database> <-CR

second line:

Third line:
<Screens>4:27;5:12;6:5;7:26;8:5;9:5;10:11;11:11;16:6;17:6;13:25;12:25;19:19;18:25</Screens> <-CRLF


Dim txtIN As List
txtIN = File.ReadList(mGlobal.BuildPath, "CurrentDB.Schema")

Result in txtIN after this code:

txtIN.Get(0)<- the weird empty string
txtIN.Get(1) <Database>FYTO_Alain.sq3</Database>
txtIN.Get(3) <Screens>4:27;5:12;6:5;7:26;8:5;9:5;10:11;11:11;16:6;17:6;13:25;12:25;19:19;18:25</Screens>
txtIN.Get(4)<- an ampty string, but this one makes sence as there is an CRLF at the end, ergo ReadList makes two lines
Upvote 0


Well-Known Member
Licensed User
My first instinct in cases like these is to check character encoding. Is it one encoding and ReadList expects another?

Otherwise, simplify. Make a simple file (in a texteditor) with, say, A, B, C and D in it, just to make sure there isn't anything you don't see in the data. If this doesn't work, it's probably Erel's problem, if it works, well, then you can gradually do more complex test cases until you find the problem.
Upvote 0


Licensed User
Ok , found it. Just for further reference if someone else encouters this.

The problem is the mix of the two type of EOLs I used. If I use all CR chars OR all CRLFs, readlist works as expected.

But because in my case I used CR for every line, and CRLF at the end, ReadList() somehow got confused.
Upvote 0