当前位置: 首页>>代码示例>>Java>>正文


Java Connection.close方法代码示例

本文整理汇总了Java中javax.microedition.io.Connection.close方法的典型用法代码示例。如果您正苦于以下问题:Java Connection.close方法的具体用法?Java Connection.close怎么用?Java Connection.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.microedition.io.Connection的用法示例。


在下文中一共展示了Connection.close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cleanUp

import javax.microedition.io.Connection; //导入方法依赖的package包/类
/**
 * @param con
 *            the connection
 */
private void cleanUp(Connection con) {
    if (con != null) {
        try {
            con.close();
        } catch (IOException e) {
            // ignore
        }
    }

}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:15,代码来源:BTTransportMethod.java

示例2: findType

import javax.microedition.io.Connection; //导入方法依赖的package包/类
/**
 * Finds the type of the content in this Invocation.
 * <p>
 * The calling thread blocks while the type is being determined.
 * If a network access is needed there may be an associated delay.
 *
 * @return the content type.
 *          May be <code>null</code> if the type can not be determined.
 *
 * @exception IOException if access to the content fails
 * @exception IllegalArgumentException if the content is accessed via
 *  the URL and the URL is invalid
 * @exception SecurityException is thrown if access to the content
 *  is required and is not permitted
 */
String findType() throws IOException, SecurityException {
    String type = null;
    Connection conn = openPrim(true);
    if (conn instanceof ContentConnection) {
    	if( conn instanceof HttpConnection ){
    		HttpConnection hc = (HttpConnection)conn;
         hc.setRequestMethod(HttpConnection.HEAD);
	
         // actual connection performed, some delay...
         if (hc.getResponseCode() != HttpConnection.HTTP_OK)
         	return null;
    	}
    	
        type = ((ContentConnection)conn).getType();
        conn.close();

        if (type != null) {
            // Check for and remove any parameters (rfc2616)
            int ndx = type.indexOf(';');
            if (ndx >= 0) {
                type = type.substring(0, ndx);
            }
            type = type.trim();
            if (type.length() == 0) {
                type = null;
            }
        }
    }

    return type;
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:47,代码来源:ContentReader.java

示例3: testUrl

import javax.microedition.io.Connection; //导入方法依赖的package包/类
public static boolean testUrl(String server, String protocol, int channel) throws IOException{

	String url = protocol + server + ":" + channel;
	String fullurl = url + ";authenticate=false;encrypt=false";
	try{
		
		Connection con = Connector.open(fullurl, Connector.READ_WRITE, true);
		PrintUtil.out.println(url + " -> Open Channel!!! " + con.getClass().getSimpleName());
		con.close();
		return true;
	}catch(IllegalArgumentException a){  
	
	}catch(Exception e){
		
		String msg = e.getMessage();
		
		if (!msg.contains("0xe00002cd") && !msg.contains("timeout")){
		
			PrintUtil.out.println(url + " -\\> " + msg);
			//e.printStackTrace();
		}
		
		return false;
	}
	
	return true;
}
 
开发者ID:ieee8023,项目名称:blucat,代码行数:28,代码来源:ScanServices.java


注:本文中的javax.microedition.io.Connection.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。