I
Ike
I have to read from a Socket, every second, and if a value returned from the
socket changes, I need to do something. The data in the input stream
terminates with a (char)0x0d (ASCII 13).
Thus, I am each second, filling a char array until the terminating character
is reached, then, converting the char array to String, as follows below:
char c4[] = new char[1024];
is = new BufferedReader(new InputStreamReader(sock.getInputStream()));
while((c3=(char)is.read())!=(char)0x0d){
i++;
c4=c3;
}
String returnedString =new String(c4); //its a shame I cannot extend String
somehow to be ascii 13 terminated!
I think there are some much more efficient ways to do what I am trying to do
here (for one, I am recreating a new String each second!). In addition, I am
wondering if I am slowing things down by using a BufferedReader as opposed
to a straight InputStreamReader.
Can anyone point out ways I can make this more efficient? Thanks, Ike
socket changes, I need to do something. The data in the input stream
terminates with a (char)0x0d (ASCII 13).
Thus, I am each second, filling a char array until the terminating character
is reached, then, converting the char array to String, as follows below:
char c4[] = new char[1024];
is = new BufferedReader(new InputStreamReader(sock.getInputStream()));
while((c3=(char)is.read())!=(char)0x0d){
i++;
c4=c3;
}
String returnedString =new String(c4); //its a shame I cannot extend String
somehow to be ascii 13 terminated!
I think there are some much more efficient ways to do what I am trying to do
here (for one, I am recreating a new String each second!). In addition, I am
wondering if I am slowing things down by using a BufferedReader as opposed
to a straight InputStreamReader.
Can anyone point out ways I can make this more efficient? Thanks, Ike