javax.microedition.io.package.html Maven / Gradle / Ivy
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:
- File - as defined by the CDC java.io.File* specifications
and the Generic Connection Framework "file:" protocol (see below)
- Datagram Socket - as defined by the CDC
java.net.DatagramSocket specification and Generic Connection Framework
"datagram:" (see below)
- Supports the following javax.microedition.io.Connector
protocols:
"file:" and "datagram:" (see below for more information on format)
The Generic Connection Framework of CDC must behave as defined
below for the following protocols:
1. File URLs as defined by RFC 1738
(http://www.w3.org/Addressing/rfc1738.txt) of the form "file://{path}" must return an object that
implements either javax.microedition.io.InputConnection (for "read"
mode), javax.microedition.io.OutputConnection (for "write" mode) or
javax.microedition.io.StreamConnection (for "read/write" mode). At least the
"read" mode must be supported by the implementation.
2. Datagram Socket as defined by
javax.microedition.io.UDPDatagramConnection with the format
"datagram://[{host}]:{port}" must return an object with behavior that
follows the javax.microedition.io.UDPDatagramConnection interface
specification which extends the javax.microedition.io.DatagramConnection
interface.
3. Communication Port
The implementation of the GCF CommConnection interface is optional,
as it has a dependency on a serial connection of the device and it
is up to the device manufacturer whether to include it or not.
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):
- All protocols as defined by the CDC Specification
- Socket - as defined by the Foundation Profile java.net.Socket
specification and Generic Connection Framework "socket:" (see below)
- HTTP - Hypertext Transfer Protocol as defined by the Foundation
Profile java.net.URLConnection for HTTP specification and Generic Connection
Framework: "http:" (see below)
- Supports the following javax.microedition.io.Connector protocols:
From CDC: "file:" and "datagram:" (see CDC Overview for more information
on format)
"socket:" and "http:" (see below for more information on format)
The Generic Connection Framework of Foundation Profile must behave
as defined below for the following protocols:
1. All protocols as defined by the CDC specification regarding the
Generic Connection Framework.
2. TCP/IP Client Socket. URIs of the form "socket://{host}:{port}"
must
return an object with behavior that follows the
javax.microedition.io.StreamConnection
interface specification.
The streams provided by this connection are functionally equivalent
to the streams provided by the java.net.Socket
class when the
Socket(String, int)
constructor is used and no socket options are set.
TCP/IP Server Socket. URIs of the form "socket:// | socket://:{port}"
must return an object with behavior that follows the
javax.microedition.io.StreamConnectionNotifier
interface specification.
The streams provided by this connection are functionally equivalent to
the streams provided by the java.net.Socket
class returned by the
java.net.ServerSocket.accept()
method when the ServerSocket(int)
constructor is used to create the ServerSocket instance.
3. HTTP as defined by the Mobile Information Device Profile (MIDP)
javax.microedition.io.HttpConnection interface with the format
that follows the MIDP javax.microedition.io.HttpConnection URL
specification and must return an object with behavior that follows
the javax.microedition.io.HttpConnection interface specification.
The implementation of the following MIDP interfaces are optional, as they
have a dependency on SSL protocol.
- SecureConnection
- HttpsConnection
If either one or the other of SecureConnection or HttpsConnection
is implemented, or if the Java Secure Socket Extension (JSSE) part
of the Java ME 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.