Provides a simplified mechanism for applications to use various types of I/O protocols in resource-constrained environments. I/O is performed by means of Connections obtained through the Connector factory class. Connections are dynamically created based on URIs of the form: {scheme}:[{target}][{params}] Please see the Connector class for more information.

Protocol Support (CDC)

The following connection protocols must be supported for CDC:


For the protocols above, the {host} parameter can either be a machine name, such as "www.jcp.org", or a string representing its IP address, such as "206.26.48.100".

Protocol Support (CDC/Foundation Profile)

The following connection protocols must be supported for CDC/Foundation Profile (only when Foundation Profile is present):

The implementation of the following MIDP interfaces are optional, as they have a dependency on SSL protocol.

If either one or the other of SecureConnection or HttpsConnection is implemented, or if the Java Secure Socket Extension (JSSE) part of the J2ME Security Optional Package is present, both of these two specific interfaces (SecureConnection and HttpsConnection) must be implemented as well.


For the protocols above, the {host} parameter can either be a machine name, such as "www.jcp.org", or a string representing its IP address, such as "206.26.48.100".

Generic Connection Framework (GCF) Security Checks (for CDC)

Access to connections of the required protocol types via the methods of javax.microedition.io.Connector is governed by certain java.lang.SecurityManager checks, as described below for CDC:

Protocol URI Form Security Check
File I/O file://{path} (reading)

file://{path} (writing)
checkRead({path})

checkWrite({path})
Datagram Socket datagram://{host}:{port}

datagram://:{port}
checkListen(0)

checkListen({port})

The methods javax.microedition.io.InputConnection.openDataInputStream() and javax.microedition.io.InputConnection.openInputStream() result in security checks, as described below:

Protocol URI Form Security Check
File Input file://{path} checkRead({path})

The methods javax.microedition.io.OutputConnection.openDataOutputStream() and javax.microedition.io.OutputConnection.openOutputStream() result in security checks, as described below:

Protocol URI Form Security Check
File Output file://{path} checkWrite({path})


Generic Connection Framework (GCF) Security Checks (for CDC/Foundation Profile)

Access to connections of the required protocol types via the methods of javax.microedition.io.Connector is governed by certain java.lang.SecurityManager checks, as described below for CDC/Foundation Profile (only when Foundation Profile is present):

Protocol URI Form Security Check
TCP/IP Client Socket socket://{host}:{port} checkConnect({host}, {port})
TCP/IP Server Socket socket://:{port} checkListen({port})
HTTP 1.1 http://{host}[{path}]

http://{host}:{port}[{path}]
checkConnect({host}, 80)

checkConnect({host}, {port})
HTTPS https://{host}[{path}]

http://{host}:{port}[{path}]
checkConnect({host}, 443)

checkConnect({host}, {port})
Secure Socket ssl://{host}:{port} checkConnect({host}, {port})
File I/O file://{path} (reading)

file://{path} (writing)
checkRead({path})

checkWrite({path})
Datagram Socket datagram://{host}:{port}

datagram://:{port}
checkListen(0)

checkListen({port})

The methods javax.microedition.io.InputConnection.openDataInputStream() and javax.microedition.io.InputConnection.openInputStream() result in security checks, as described below:

Protocol URI Form Security Check
HTTP 1.1 http://{host}[{path}]

http://{host}:{port}[{path}]
checkConnect({host}, 80)

checkConnect({host}, {port})
HTTPS https://{host}[{path}]

http://{host}:{port}[{path}]
checkConnect({host}, 443)

checkConnect({host}, {port})
Secure Socket ssl://{host}:{port} checkConnect({host}, {port})
File Input file://{path} checkRead({path})

The methods javax.microedition.io.OutputConnection.openDataOutputStream() and javax.microedition.io.OutputConnection.openOutputStream() result in security checks, as described below:

Protocol URI Form Security Check
HTTP 1.1 http://{host}[{path}]

http://{host}:{port}[{path}]
checkConnect({host}, 80)

checkConnect({host}, {port})
HTTPS https://{host}[{path}]

http://{host}:{port}[{path}]
checkConnect({host}, 443)

checkConnect({host}, {port})
Secure Socket ssl://{host}:{port} checkConnect({host}, {port})
File Output file://{path} checkWrite({path})




StreamConnection Behavior

Opening a DataInputStream counts as opening an InputStream and opening a DataOutputStream counts as opening an OutputStream. In Foundation Profile, multiple streams may be opened by one StreamConnection. Trying to open another InputStream or another OutputStream from a StreamConnection must not cause any exception. Trying to open InputStream or OutputStream after they have been closed causes an IOException.

After calling the close method, regardless of open streams, further method calls to connection will result in IOExceptions for those methods that are declared to throw IOExceptions. For the methods that do not throw exceptions, unknown results may be returned.