Sana Bokhari wrote:hey i am reading a file byte by byte..., then storing it in a byte array and lastly converting it to a string...
First mistake. Bytes and characters are not the same thing. They can be converted; though this is usually done by using either
(a) a BufferedReader, or
(b) one of the String constructors that takes a byte array.
but this really only works if what you are reading in is text. If it's binary, you really DON'T want a String.
but i want to convert values on every index of the byte array individually..... i.e. what ever bytes i have on index one should be converted to string.....
And here's where my confusion starts. Are you saying that if you read in a byte that contains an ascii 'a', you want it to print out as '97'?
Because that's what your code will do.
Furthermore, if you simply concatenate all those numbers together, you will never be able to get your original values back, because the strings produced may be of different lengths. You could zero-fill them to some uniform length, but it seems like an awful lot of "noise code" to me.
My suggestion is this: back up and explain
exactly what it is you're trying to do (NOT what you've done)
and why. That might help us suggest a solution.
Also: provide some examples of what you want, because at the moment your requirements mystify me.
Winston