How to convert hex string to octal string in java -


i converting string hexadecimal string , want convert octal string

i doing follows

string s="i found reason 2 days ago bussy update you.the problem udhl missing. should have added 06 @ beginning.  works fine.for reason thought kannel adds (not difficult...), know doesn't...";   string hex = string.format("%040x", new biginteger(1, s.getbytes("utf-8")));     

output is

4920666f756e642074686520726561736f6e203220646179732061676f20692077617320746f6f20627573737920746f2075706461746520796f752e5468652070726f626c656d20776173207468617420746865205544484c20776173206d697373696e672e20492073686f756c6420686176652061646465642030362061742074686520626567696e6e696e672e2020697420616c6c20776f726b732066696e652e466f7220736f6d6520726561736f6e20492074686f75676874206b616e6e656c2061646473207468697320627920697473656c6620286e6f74207665727920646966666963756c742e2e2e292c20627574206e6f772049206b6e6f7720697420646f65736e27742e2e2e 

i need convert hex octal string. tried this

string octal = integer.tooctalstring(integer.parseint(hex,16)); 

but expected gave me number format exception hex string have characters in it.

i want know how can conver hex string octal string.

as per discussion in comments, want convert each byte individually , convert them octal:

string s     = "my string convert"; byte[] bytes = s.getbytes("utf-8");  (byte b : bytes) {     string octalvalue = integer.tostring(b, 8);      // whatever } 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -