AW: [SNMP4J] problem with declaring octet Variable
Ali Daher
alidaher at gebecom.de
Mon Jan 12 17:48:20 CET 2009
Thanks Jon for your reply.
I tried the following:
String stringToConvert = "10101110";
int i = Integer.parseInt(
stringToConvert,16);
byte[] dword = new byte[4];
dword[0] = (byte) ((i >>> 24) &
0x000000FF);
dword[1] = (byte) ((i >>> 16) &
0x000000FF);
dword[2] = (byte) ((i >>> 8) &
0x000000FF);
dword[3] = (byte) (i & 0x00FF);
var2 = new OctetString(dword);
I checked wireshark... and it is sending "10101110" a set value, and that's
good.
But unfortunately I am still getting wrong value as a response.
I was wondering it can be that the string itself is missing something. For
example it should be:
String stringToConvert = "1010111000000000" since there are other actions
and I have to determine whether they are 0 or 1. In this case I am facing
the problem to convert the string to int. and I am getting the following
exception: Exception in thread "main" java.lang.NumberFormatException: For
input string: "0110111000000000".
I know that seems a none snmp4j question but a help is appreciated
Thanks again
Ali
-----Ursprüngliche Nachricht-----
Von: snmp4j-bounces at agentpp.org [mailto:snmp4j-bounces at agentpp.org] Im
Auftrag von Jon Ruano
Gesendet: Montag, 12. Januar 2009 16:07
An: snmp4j at agentpp.org
Betreff: Re: [SNMP4J] problem with declaring octet Variable
Integer.parseInt( String s, int radix ) is what you want to get the
integer value of what 'value' represents as a binary number, and not
as a character string.
Jon
_______________________________________________
SNMP4J mailing list
SNMP4J at agentpp.org
http://lists.agentpp.org/mailman/listinfo/snmp4j
More information about the SNMP4J
mailing list