×
Namespaces

Variants
Actions

How to close a network connection in Java ME

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: User:Spider Eg (20 Mar 2007)
Last edited: hamishwillee (27 Jul 2013)

Closing the Network Connection should be in the finally brackets to avoid any exception happen while openning or while reading and writing

HttpConnection Conn=null;
try
{
Conn=(HttpConnection)Connector.open(URL);//Opening
/*
Code here to read and write on this connection
*/

}//closing the try
catch(Exception _Ex)
{
}//catching any exception occurs
finally
{
try
{
if( Conn!=null )
Conn.close();//Closing
}
catch(Exception _Ex)
{
}
}//Closing the finally
This page was last modified on 27 July 2013, at 03:38.
39 page views in the last 30 days.
×