is there a comperable codenameone class to java.io.ObjectInputStream;

21 views
Skip to first unread message

shop.servic...@gmail.com

unread,
Jun 11, 2017, 6:55:49 PM6/11/17
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans 8.1
Java 1.8.0_131
Simulator
Device

C:\Src1\ShopServiceAsst\AstcTechMobileApp\src\com\astc\a3tech\Util\A3Include.java:24: error: cannot find symbol
import java.io.ObjectInputStream;
  symbol:   class ObjectInputStream
  location: package java.io

I see that codenameone can write and read a java.util.Vector

I can convert a Vector to bytes from my Server, send them to the Client VIA TCP and save to disk, however when I use

            Object obj = sendCmdToServerWithResponse(host.getText(), Port, CMD, null, socketTimeOut);
            Storage.getInstance().writeObject("Companies", (Vector)obj);
            Vector<String> vec = (Vector) Storage.getInstance().readObject("Companies");
I get java.lang.ClassCastException: [B cannot be cast to java.util.Vector

Shai Almog

unread,
Jun 11, 2017, 11:58:53 PM6/11/17
to CodenameOne Discussions, shop.servic...@gmail.com
You can use Util.writeObject() with DataOutputStream.
You can use Storage.writeObject() too.

Notice your objects need to support externalization as explained in the developer guide.
Reply all
Reply to author
Forward
0 new messages