Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

input stream to string tooooo slow

807607Nov 5 2006 — edited Nov 5 2006
hi 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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 3 2006
Added on Nov 5 2006
57 comments
1,582 views