Giusy Active Member Licensed User Oct 4, 2018 #1 Hi, I read a txt file so: Code: Copy tr.Initialize(File.OpenInput(File.DirInternal, "PARAMETRI.txt")) ROWs=16 For SS = 1 To ROWs strlines = tr.ReadLine .... Next tr.Close But I do not Know how to write a file Code: Copy tr.Initialize(File.OpenOutput(File.DirInternal, "PARAMETRI.txt",False)) ??? Can someone help me?
Hi, I read a txt file so: Code: Copy tr.Initialize(File.OpenInput(File.DirInternal, "PARAMETRI.txt")) ROWs=16 For SS = 1 To ROWs strlines = tr.ReadLine .... Next tr.Close But I do not Know how to write a file Code: Copy tr.Initialize(File.OpenOutput(File.DirInternal, "PARAMETRI.txt",False)) ??? Can someone help me?
Eme Fibonacci Well-Known Member Licensed User Longtime User Oct 4, 2018 #2 Code: Copy Dim TextWriter1 As TextWriter TextWriter1.Initialize(File.OpenOutput(File.DirRootExternal, "Text.txt", False)) For i = 1 To 10 TextWriter1.WriteLine("Line" & i) Next TextWriter1.Close From tutorial https://www.b4x.com/android/forum/threads/text-files.6690/#content Upvote 0
Code: Copy Dim TextWriter1 As TextWriter TextWriter1.Initialize(File.OpenOutput(File.DirRootExternal, "Text.txt", False)) For i = 1 To 10 TextWriter1.WriteLine("Line" & i) Next TextWriter1.Close From tutorial https://www.b4x.com/android/forum/threads/text-files.6690/#content
MarkusR Well-Known Member Licensed User Longtime User Oct 4, 2018 #4 ROWs=16 Click to expand... if u write the count of lines before its easier to read. u can also save/load a map (key/value) with File. Upvote 0
ROWs=16 Click to expand... if u write the count of lines before its easier to read. u can also save/load a map (key/value) with File.
R Roycefer Well-Known Member Licensed User Longtime User Oct 4, 2018 #5 Erel is going to yell at you for using TextReader and TextWriter. I predict he'll say that in most cases, you are better off using File.ReadList and File.WriteList or similar methods. Upvote 0
Erel is going to yell at you for using TextReader and TextWriter. I predict he'll say that in most cases, you are better off using File.ReadList and File.WriteList or similar methods.
Erel B4X founder Staff member Licensed User Longtime User Oct 7, 2018 #6 That's true. The only reason to use TextReader / TextWriter is if you want to use an encoding other than UTF8. Upvote 0
That's true. The only reason to use TextReader / TextWriter is if you want to use an encoding other than UTF8.