A= term_to_binary({100,200,123,45}) ,
io:format("~p~n",[A]),
mongo:save(?IP_ADDRESS, {'_id', 1, ip,A}).
the result is <<131,104,4,97,100,97,200,97,123,97,45>>
and I need to read it in java
DBObject a = IpTable.findOne(new BasicDBObject("_id",1));
byte[] t=null;
try
{
String u = a.get("ip").toString();
System.out.println(u);
t= u.getBytes("ISO8859-1");
}
catch(Exception ex)
{
}
for(int i=0;i<t.length;i++)
System.out.print(t[i]+",");
System.out.println();
the result is
63,104,4,97,100,98,0,0,7,63,97,123,97,45,
if I change the first bytes into 131
t[0]=(byte)131;
try
{
OtpInputStream ois = null;
ois = new OtpInputStream(t);
OtpErlangTuple IP = (OtpErlangTuple)OtpErlangObject.decode(ois);
System.out.println(IP);}
the result is {100,63,123,45} is wrong