I use following code to read data form http request. In general cases it works good, but some time "httpURLConnection.getResponseCode()" throws java.net.BindException: Address already in use: connect
............
URL url = new URL( strUrl );
httpURLConnection = (HttpURLConnection)url.openConnection();
int responseCode = httpURLConnection.getResponseCode();
char charData[] = new char[HTTP_READ_BLOCK_SIZE];
isrData = new InputStreamReader( httpURLConnection.getInputStream(), strCharset );
int iSize = isrData.read( charData, 0, HTTP_READ_BLOCK_SIZE );
while( iSize > 0 ){
sbData.append( charData, 0, iSize );
iSize = isrData.read( charData, 0, HTTP_READ_BLOCK_SIZE );
}
.................
finally{
try{
if( null != isrData ){
isrData.close();
isrData = null;
}
if( null != httpURLConnection ){
httpURLConnection.disconnect();
httpURLConnection = null;
}
strData = sbData.toString();
}
catch( Exception e2 ){
}
The code running on Java 1.6, Tomcat 6. Thank you