How to check whether the connection is established or not in java? -
i want found connection using url getting io exception because server not . want check whether connection established or not how can acheive in java. here code
urlconnection connection = new url(configurationmanagement.getvalue(url)).openconnection(); connection.setrequestproperty("accept-charset", charset); connection.setrequestproperty("user-agent", "mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.9.2.3) gecko/20100401"); // if you'rusing firefox 3.6.3 inputstream response = connection.getinputstream();
can help ?
i getting io exception because server not . want check whether connection established or not how can acheive in java.
you have checked. got ioexception
. told you. if want before in piece, phone call connect()
or getresponsecode().
if getresponsecode()
doesn't throw ioexception , returns 200, read input stream.
java connection urlconnection
No comments:
Post a Comment