Sub SendObject (Obj As Object)
raf.WriteObject(Obj, True, 0)
Dim size As Int = raf.CurrentPosition
Dim data(size) As Byte
raf.CurrentPosition = 0
Do While raf.CurrentPosition < size
raf.ReadBytes(data, raf.CurrentPosition, size - raf.CurrentPosition, _
raf.CurrentPosition)
Loop
Dim j As HttpJob
j.Initialize("send object", Me)
j.PostBytes(link & "/Attendee_Location", data)
End Sub
and this is "ReadObject" coding
B4X:
Public Sub ReadObject (In As InputStream) As Object
Dim out As OutputStream
out.InitializeToBytesArray(0)
File.Copy2(In, out)
Dim raf2 As RandomAccessFile
raf2.Initialize3(out.ToBytesArray, False)
Dim res As Object = raf2.ReadObject(0)
raf2.Close
Return res
End Sub
How can i convert to B4i code. I try many times and no luck
Please help me.
Sub SendObject (Obj As Object)
raf.WriteB4XObject(Obj, True, 0)
Dim size As Int = raf.CurrentPosition
Dim data(size) As Byte
raf.CurrentPosition = 0
Do While raf.CurrentPosition < size
raf.ReadBytes(data, raf.CurrentPosition, size - raf.CurrentPosition, _
raf.CurrentPosition)
Loop
Dim j As HttpJob
j.Initialize("send object", Me)
j.PostBytes(link & "/Attendee_Location", data)
End Sub
I found an error "Too Many Parameter" at raf.WriteB4XObject(Obj, True, 0) ,
If i change to raf.WriteB4XObject(Obj, 0) then i got an error "CurrentPosition is Readonly" at raf.CurrentPosition = 0
Please help me, i stuck at here.
CurrentPosition was mistakenly marked as readonly.
I've uploaded v1.01 to the hosted builders that fixes this issue. You should update the xml file and it will fix it.
CurrentPosition already fixed. Another problem occur, when i debug the coding "Dim res As Object = raf2.ReadB4XObject(0)".
I get the following error message..
You cannot use B4A/B4J raf.WriteObject with B4i. You will need to either wait for WriteB4XObject to be ported to B4A/B4J or use a different serialization method.