Caucho Forums  

This forum is permanently closed because of spam. For free community support, please visit Google Groups:

Go Back   Caucho Forums > Hessian

Thread Tools Display Modes
Old 01-09-2014, 11:37 PM
netsql netsql is offline
Junior Member
Join Date: Feb 2010
Posts: 7
Default Encode a map, decode a map (using Hessian)

This code fails, cut/paste. Please help me encode a map to byte[], and decode a map. (I'll send it myself to server). tia

public static void main(String[] args) throws Exception {
Map row = new HashMap();
row.put("a", 1);
ByteBuffer b = encMap(row);

Map ret = decMap(b);

public static ByteBuffer encMap(Map map) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Hessian2Output out= new Hessian2Output(bos);
Serializer ser = HFac.getSerializerFactory().getSerializer(Map.clas s);
byte[] b = bos.toByteArray();
return ByteBuffer.wrap(b);

public static Map<String, Object> decMap(ByteBuffer bb) throws IOException {
InputStream bs = new ByteArrayInputStream(bb.array());
Hessian2Input in = HFac.createHessian2Input(bs);
Deserializer der = HFac.getSerializerFactory().getDeserializer( ass);
Map m2 = (Map) der.readMap(in);
return m2;
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 07:56 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.