java - Convert hash table to byte array -


i have hash table , want send through datagram socket. need have byte array. how can convert hash table byte array? i've ignore filling hash table i've tried way:

    hashtable<string, string> valuenick = new hashtable<>();     nickstr = valuenick.tostring();     byte[] buffernick = nickstr.getbytes();     (int = 0; < buffernick.length; i++) {              system.out.print(buffernick[i] + " ");         } 

but nothing has been printed. or advise.

i have modified code(added value in it)

hashtable<string, string> valuenick = new hashtable<>();         valuenick.put("name", "ankush");     valuenick.put("lastname", "soni");         string nickstr = valuenick.tostring();         byte[] buffernick = nickstr.getbytes();         (int = 0; < buffernick.length; i++) {                  system.out.print(buffernick[i] + " ");             }   } 

it printing below output:

123 108 97 115 116 78 97 109 101 61 83 111 110 105 44 32 110 97 109 101 61 65 110 107 117 115 104 125

edit: empty hashtable able print byte data is

123 125


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -