random access files

skywalker34

Member
Licensed User
Longtime User
Hi,

I have to open a file created outside than contain image coding (for printer)
the coding is something like "1B 2A ......." in hexadecimal view

I have to get each of those code one by one to send it to the printer with chr(code)

I wrote this :

Sub Button4_Click

Dim code2send
Dim f As RandomAccessFile
If File.Exists(File.DirAssets, "061.log") Then
File.Copy(File.DirAssets, "061.log", File.DirInternal, "061.log")
f.Initialize(File.DirInternal, "061.log",True)
Log(f.CurrentPosition & "/" & f.Size)

Do While (f.CurrentPosition < f.Size )
Log(f.CurrentPosition & "/" & f.Size)
code2send = f.ReadObject(f.CurrentPosition)
Log (Chr(code2send))
Loop
f.Close
File.Delete (File.DirInternal, "061.log")
End If

but this crash on code2send=f.ReadObject....

messages in the log :

0/3604

main_button4_click (B4A line: 228)

code2send = f.ReadObject(f.CurrentPosition)
java.lang.OutOfMemoryError


at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.readHelper(RandomAccessFile.java:375)
at anywheresoftware.b4a.randomaccessfile.RandomAccessFile.ReadObject(RandomAccessFile.java:362)
at bt.spp.printing.main._button4_click(main.java:461)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:155)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:151)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:59)
at android.view.View.performClick(View.java:3517)
at android.view.View$PerformClick.run(View.java:14155)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4524)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
at dalvik.system.NativeStart.main(Native Method)
 
Last edited:
Top