B4J Question [BANano] Load txt from assets

angel_

Well-Known Member
Licensed User
Longtime User
How can you load the text from txt file in assets?, I tried something like this thread:


B4X:
Dim blob As BANanoObject = BANano.Await(BANano.GetFileAsText("./assets/myfile.txt", Null, "UTF-8"))

Dim MyText As String = blob.ToString

BANano.Console.Log(MyText)
'...'

But it doesn't work, what am I doing wrong?
 
Solution
Why are you using a blob in this case? GetFileAsText already returns the string. The example above using blob is because the OP wanted the 'file' (not the contents) so he could get its size, last modification etc.

B4X:
Dim myText as String = BANano.Await(BANano.GetFileAsText("./assets/myfile.txt", Null, "UTF-8"))
log(myText)

Alwaysbusy

alwaysbusy

Expert
Licensed User
Longtime User
Why are you using a blob in this case? GetFileAsText already returns the string. The example above using blob is because the OP wanted the 'file' (not the contents) so he could get its size, last modification etc.

B4X:
Dim myText as String = BANano.Await(BANano.GetFileAsText("./assets/myfile.txt", Null, "UTF-8"))
log(myText)

Alwaysbusy
 
Upvote 1
Solution
Cookies are required to use this site. You must accept them to continue using the site. Learn more…