Hi all. Ive been creating a text file using TextWriter.
When I examine the result, it has been truncated at 04000 Hex bytes in size.. it's incomplete.
Is this an Android limit, or TextWriter, or what?
Third option. I guess that you logged the file content. Log truncates messages longer than 4000 characters. TextWriter or File.WriteString will never truncate anything. If there isn't enough memory (and there is) then there will be an error.
Tip: don't use TextWriter. Use File.WriteString or WriteList.
Hmm.
Wasnt using logging.. just a loop with TextWriter.
I did want to process each item in my list with a replace() as they were written out.
To make a single writable string for WriteString, Id have to join a lot of strings, and that takes a very long time when debugging. (not on release, but I do need to debug)
I'm also fighting with TextWriter during my attempts to port code to multiple platforms, since TextWriter is not available in B4i.
As I'm writing one line a time as they are produced (actually a logging module), File.WriteString or File.WriteList are not suitable, since they write all the file at once, with no append option available.
Or am I missing something?
I was using s = s & <newvalue>
I've switched to Writelist and that seems to work (instead of writing line by line, I now add to a list then dump the lot) , but I suspect a bug in TextWriter.
I was using s = s & <newvalue>
I've switched to Writelist and that seems to work (instead of writing line by line, I now add to a list then dump the lot) , but I suspect a bug in TextWriter.
looks like a waste of memory and processing time, building a new string every time and rewriting the file.
if something bad happens in between, you’re losing the whole file, which defies the purpose of a progressive log, in my use case
Public Sub LogToFile (msg As String)
Dim out As OutputStream = File.OpenOutput(xui.DefaultFolder, "log.txt", True)
'you might want to add: msg = msg & CRLF
Dim b() As Byte = msg.GetBytes("UTF8")
out.WriteBytes(b, 0, b.Length)
out.Close
End Sub
Public Sub LogToFile (msg As String)
Dim out As OutputStream = File.OpenOutput(xui.DefaultFolder, "log.txt", True)
'you might want to add: msg = msg & CRLF
Dim b() As Byte = msg.GetBytes("UTF8")
out.WriteBytes(b, 0, b.Length)
out.Close
End Sub
Dear friends,
I am using TextWriter in one of my B4J based projects. The files are created as soon as I get MQTT message. Can it be the reason , that after a month or so of logging, I get GC limit error? I had raised this question and Erel suggested me to check the dump file, but it was not possible due to client location.
[B4X Tool] - B4XIDEViewer V. 1.0 What is B4XIDEViewer? -It’s a B4X Tool which can show bitmaps, images and saved pictures from your B4XIDE on your computer. You can also play video and audio files present on your device. You can transfer files from the device. You can show and search huge text...