My Thoughts : http://passion4java.blogspot.com
Try not to become a man of success but rather to become a man of value.
Mohammed Yousuff wrote:Hi i was trying to convert from char[] to a byte[] (with out using String class). i was unable to find any API which does this... then i written a sample code which converts from char[] to byte[]... it works...
in my code, i am looping the char[] and converting every element to byte... some where in the net i read that their are some chances to loose data while you convert like this?. is that true?...
let me know is there any better approach we have to do this conversion? thank you>
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
My Thoughts : http://passion4java.blogspot.com
Try not to become a man of success but rather to become a man of value.
Mohammed Yousuff wrote:Thanks a lot James, the reason is i want to pass my char[] to a method which expects byte[].... I understand that the same can be done using String class API, but we don't want to use that...Can you please suggest some other options if available.. thanks for your help.
My Thoughts : http://passion4java.blogspot.com
Try not to become a man of success but rather to become a man of value.
Mohammed Yousuff wrote:I got it Henry.Let me explain what i am trying to do...The current code accepts parameter as string and converts the string to byte[] using string.toByteArray()... What we are trying to is similar rather than accepting string we want to pass char[] and that should be converted to byte[]... currently all our inputs will not contain any internalization chars it only English and numbers.
i think in this scenario, the code which i have written will work without any issues?... thanks you
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
My Thoughts : http://passion4java.blogspot.com
Try not to become a man of success but rather to become a man of value.
Mohammed Yousuff wrote:James you are right, i am trying to do the same....thanks a lot your comments helps me....;)
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Mohammed Yousuff wrote:James you are right, i am trying to do the same....thanks a lot your comments helps me....;)
... currently all our inputs will not contain any internalization chars it only English and numbers.
If you believe you can tell me what to think, I believe I can tell you where to go. Go read this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|