java - How to Convert an int ByteStream to a String? -
Hi, I am trying to implement the interface source stream in my application and override the method I read (byte [], off, lane) and I read bytes from a server. But I want to convert those byte streams into strings, for which I used string objects while doing new string (byte []), but the initial byte is the length of the bytes and i.e. the query of the LAN. Why is this asking, because we only have the string (by []) anybody can help me ... thanks
If you have only one by []
You can then create provided by API string (byte [], Int, Int)
through a String
.
Your case will do you
byte [] myBytes = ("hello, world!") GetBytes (); String Maestring = new string (miciets, 0, mybank.lamp); Println (myString);
Edit: Try something like this:
int readLength = (lane> bufSize? BufSize: len); For (int i = 0; i & lt; readLength; i ++) {b [off + i] = buffer [pubf] [pibet]; } String Metast = New String (B, 0, Pail Lailanth);