Java Code Examples for javax.microedition.io.Connection#close()
The following examples show how to use
javax.microedition.io.Connection#close() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConnectorServiceImpl.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
public DataInputStream openDataInputStream(String name) throws IOException { Connection con = open(name, ConnectorService.READ, false); if (con instanceof InputConnection) { DataInputStream stream = ((InputConnection)con).openDataInputStream(); con.close(); return stream; } con.close(); throw new IOException("Given scheme does not support input"); }
Example 2
Source File: ConnectorServiceImpl.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
public DataOutputStream openDataOutputStream(String name) throws IOException { Connection con = open(name, ConnectorService.WRITE, false); if (con instanceof OutputConnection) { DataOutputStream stream = ((OutputConnection)con).openDataOutputStream(); con.close(); return stream; } con.close(); throw new IOException("Given scheme does not support output"); }
Example 3
Source File: ConnectorServiceImpl.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
public InputStream openInputStream(String name) throws IOException { Connection con = open(name, ConnectorService.READ, false); if (con instanceof InputConnection) { InputStream stream = ((InputConnection)con).openInputStream(); con.close(); return stream; } con.close(); throw new IOException("Given scheme does not support input"); }
Example 4
Source File: ConnectorServiceImpl.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
public OutputStream openOutputStream(String name) throws IOException { Connection con = open(name, ConnectorService.WRITE, false); if (con instanceof OutputConnection) { OutputStream stream = ((OutputConnection)con).openOutputStream(); con.close(); return stream; } con.close(); throw new IOException("Given scheme does not support output"); }
Example 5
Source File: ContentReader.java From pluotsorbet with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 6
Source File: ScanServices.java From blucat with GNU General Public License v2.0 | 5 votes |
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; }