input stream to string tooooo slow
807607Nov 5 2006 — edited Nov 5 2006hi guys.
im having to get the response from an input stream into a string..ive tried many methods shown on the net such as using 4096 size buffer etc but its still taking too long...it takes 50SECONDS!!!!!
i need to use string to send data to a server...i think the 50 sec delay is causing it too timeout cuz i dont get response from server when i do eventually send something.
heres the current code
StringBuffer out = new StringBuffer();
byte[] b = new byte[4096];
for (int n; (n = in.read(b)) != -1;) {
out.append(new String(b, 0, n));
}
String nsResponse = out.toString();
int tweenIndex = nsResponse.indexOf("lc=1033");
String tween = nsResponse.substring(tweenIndex).trim();
System.out.println(tween);
Come on guys pleasssssssssssssssssssssse help. its really important.