TextReader1.ReadLine Question

pixelpop

Active Member
Licensed User
Longtime User
I need to read a text file twice that I have downloaded. The first time I read the file, I use a ReadLine loop until the line read is = null. How do I reset the TextReader back to the beginning of the inputstream so I can read the file a second time?

Edit: I found that by just reinitiatizing the same inputstream using TextReader1.Initialize(Job.GetInputStream) I could read the inputstream from the beginning again.
 
Last edited:

Theera

Well-Known Member
Licensed User
Longtime User
See my example code
B4X:
   If File.Exists(File.DirDefaultExternal,"RiceName1.txt") Then
           Dim Reader1 As TextReader
         If Reader1.IsInitialized = False Then
               Reader1.Initialize(File.OpenInput(File.DirDefaultExternal,"RiceName1.txt"))
         End If
         Dim line As String
         cboBox.Clear
         cboBox.Prompt="Select one  of your lists  "
         line=Reader1.ReadLine
         Do While line <> Null
           Dim pos As Int
             pos=line.IndexOf(",")
          cboBox.Add(line.SubString2(0,pos))
          line=Reader1.ReadLine
         Loop
         Reader1.Close
   End If
 
Upvote 0

Similar Threads

Top