java - What's the difference between new String(byte[]) and DatatypeConverter.printBase64Binary(byte[])? -


i need pass base64 encoded data xml string value. noticed code below prints different string representation. 1 correct , why?

    string example = "hello universe!";     byte[] base64data = base64.encodebase64(example.getbytes());     system.out.println(new string(base64data));     system.out.println(datatypeconverter.printbase64binary(base64data));      system.out.println(new string(base64.decodebase64(base64data), "utf-8")); 

and result:

sgvsbg8gdw5pdmvyc2uh u0dwc2jhogdkvzvwzg1wewmyvwg= hello universe! 

u0dwc2jhogdkvzvwzg1wewmyvwg= decoded sgvsbg8gdw5pdmvyc2uh hello universe! encoded. did encoding twice.

there no difference. using api wrong way. don't encode encoded data again.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -