Sub ParseFile
Dim In As InputStream = File.OpenInput(File.DirAssets, "filename.xml")
Dim tr As TextReader
tr.Initialize2(In, "ASCII")
Dim buffer(1) As Char
Dim sb As StringBuilder
sb.Initialize
Do Until sb.ToString.EndsWith("<GetReportResult>")
tr.Read(buffer, 0, 1)
sb.Append(buffer(0))
Loop
Dim base64File As OutputStream = File.OpenOutput(File.DirRootExternal, "1.base64", False)
Dim tbase64File As TextWriter
tbase64File.Initialize2(base64File, "ASCII")
Dim count As Int
Do While True
tr.Read(buffer, 0, 1)
If buffer(0) = "<" Then Exit
tbase64File.Write(buffer(0))
count = count + 1
If count Mod 1000 = 0 Then Log(count)
Loop
tbase64File.Close
Dim In As InputStream = File.OpenInput(File.DirRootExternal, "1.base64")
Dim bis As JavaObject
bis.InitializeNewInstance("android.util.Base64InputStream", Array(In, 0))
Dim bb(8192) As Byte
Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "1.pdf", False)
Dim count As Int = bis.RunMethod("read", Array(bb, 0, bb.Length))
Do While count > 0
out.WriteBytes(bb, 0, count)
Dim count As Int = bis.RunMethod("read", Array(bb, 0, bb.Length))
Loop
out.Close
End Sub