Eme Fibonacci Well-Known Member Licensed User Longtime User Nov 13, 2015 #1 How parse a Stored inputStream? Globals: Dim XMLTopics as inputStream I have a sub: Sub ParseTopics (parsePar as InputStream) Parser.parse (ParserPar, "MyParser") If XMLtopics.IsInitialized = False Then XMLtopics = parsePar end If end Sub If parsePar is the result of a jobdone it works: ParseTopics (Job.GetInputStream) ---> Ok. But if at another time I try: ParseTopics (XMLtopics) ---> It don´t works. Error: java.io.IOException: BufferedInputStream is closed Thank you for your help.
How parse a Stored inputStream? Globals: Dim XMLTopics as inputStream I have a sub: Sub ParseTopics (parsePar as InputStream) Parser.parse (ParserPar, "MyParser") If XMLtopics.IsInitialized = False Then XMLtopics = parsePar end If end Sub If parsePar is the result of a jobdone it works: ParseTopics (Job.GetInputStream) ---> Ok. But if at another time I try: ParseTopics (XMLtopics) ---> It don´t works. Error: java.io.IOException: BufferedInputStream is closed Thank you for your help.
Ohanian Active Member Licensed User Longtime User Nov 13, 2015 #2 Hi, try this : Code: Copy Dim Parser As JSONParser Dim ParserPar As InputStream ParserPar = File.OpenInput(File.DirAssets, "file.name") Parser.parse (ParserPar, "MyParser") Upvote 0
Hi, try this : Code: Copy Dim Parser As JSONParser Dim ParserPar As InputStream ParserPar = File.OpenInput(File.DirAssets, "file.name") Parser.parse (ParserPar, "MyParser")
Eme Fibonacci Well-Known Member Licensed User Longtime User Nov 14, 2015 #3 Sorry about my English. I have a global variable: Dim XMLtopics as InputStream I get parsePar as the result of a jobdone ( Job.GetInputStream) Sub ParseTopics (parsePar as InputStream) Log (XMLtopics.IsInitialized) --> return false XMLtopics = parsePar parser.parse (XMLtopics, "Parser3") -->works Log (XMLtopics.IsInitialized) --> return true Parser. Parse (XMLtopics, "Parser3") --> error Error: java.io.IOException: BufferedInputStream is closed at java.io.BufferedInputStream.streamClosed(BufferedInputStream.java:118)end Sub Why I can not reuse XMLTopics? (in this sub and others subs) Thank you. Upvote 0
Sorry about my English. I have a global variable: Dim XMLtopics as InputStream I get parsePar as the result of a jobdone ( Job.GetInputStream) Sub ParseTopics (parsePar as InputStream) Log (XMLtopics.IsInitialized) --> return false XMLtopics = parsePar parser.parse (XMLtopics, "Parser3") -->works Log (XMLtopics.IsInitialized) --> return true Parser. Parse (XMLtopics, "Parser3") --> error Error: java.io.IOException: BufferedInputStream is closed at java.io.BufferedInputStream.streamClosed(BufferedInputStream.java:118)end Sub Why I can not reuse XMLTopics? (in this sub and others subs) Thank you.
Erel B4X founder Staff member Licensed User Longtime User Nov 15, 2015 #4 Eme Fibonacci said: Why I can not reuse XMLTopics? Click to expand... Because the data was already read from the input stream. Once it is read it is no longer available. If you want to read it multiple times: Code: Copy Dim data() As Byte = Bit.InputStreamToBytes(parsePar) 'You can now create an InputStream that reads from data: Dim in As InputStream in.InitializeFromBytesArray (data, 0, data.Length) Upvote 0
Eme Fibonacci said: Why I can not reuse XMLTopics? Click to expand... Because the data was already read from the input stream. Once it is read it is no longer available. If you want to read it multiple times: Code: Copy Dim data() As Byte = Bit.InputStreamToBytes(parsePar) 'You can now create an InputStream that reads from data: Dim in As InputStream in.InitializeFromBytesArray (data, 0, data.Length)