本文整理汇总了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
}
}
}
示例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;
}
示例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;
}