javax.microedition.io
Class Connector

java.lang.Object
  |
  +--javax.microedition.io.Connector

public class Connector
extends Object

The Connector.open() method returns a protocol-specific Connection object that is then used to transmit data. Before data transmission, the returned Connection object must be typecast to a protocol-specific implementation object. Class of the returned Connection object is set in the protocol scheme in the URL provided by the Connector.open() method.

The table below shows all the protocol schemes supported by the Nokia 12 GSM module and the returned Connection class for each supported protocol.

 

Scheme

Protocol

Connection class

Description and URL

http

HTTP

HttpConnection

HTTP connection over a TCP bearer.

http://www.example.com:80/index.html

socket

TCP

StreamConnection

TCP client connection.

socket://10.35.1.195:9000

socket

TCP

StreamConnectionNotifier

TCP server connection for receiving incoming TCP connections

socket://:9000

datagram

UDP

DatagramConnection

UDP socket for sending and receiving UDP datagrams.

datagram://10.35.1.195:9000

datagram://:9000

comm

Serial port

StreamConnection

Stream connection for sending and receiving data using a built-in serial port.

comm:3;baudrate=115200

sms

SMS

MessageConnection

Message connection for sending and receiving short messages.

sms://+35812345678

sms://:3000


Field Summary
static int READ
          Access mode READ.
static int READ_WRITE
          Access mode READ_WRITE.
static int WRITE
          Access mode WRITE.
 
Method Summary
static Connection open(String name)
          Create and open a Connection.
static Connection open(String name, int mode)
          Create and open a Connection.
static Connection open(String name, int mode, boolean timeouts)
          Create and open a Connection.
static DataInputStream openDataInputStream(String name)
          Create and open a connection input stream.
static DataOutputStream openDataOutputStream(String name)
          Create and open a connection output stream.
static InputStream openInputStream(String name)
          Create and open a connection input stream.
static OutputStream openOutputStream(String name)
          Create and open a connection output stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

READ

public static final int READ
Access mode READ.

See Also:
Constant Field Values

WRITE

public static final int WRITE
Access mode WRITE.

See Also:
Constant Field Values

READ_WRITE

public static final int READ_WRITE
Access mode READ_WRITE.

See Also:
Constant Field Values
Method Detail

open

public static Connection open(String name)
                       throws IOException
Create and open a Connection.

Parameters:
name - The URL for the connection.
Returns:
A new Connection object.
Throws:
IllegalArgumentException - If a parameter is invalid.
ConnectionNotFoundException - If the requested connection cannot be make, or the protocol type does not exist.
IOException - If some other kind of I/O error occurs.

open

public static Connection open(String name,
                              int mode)
                       throws IOException
Create and open a Connection.

Parameters:
name - The URL for the connection.
mode - The access mode.
Returns:
A new Connection object.
Throws:
IllegalArgumentException - If a parameter is invalid.
ConnectionNotFoundException - If the requested connection cannot be make, or the protocol type does not exist.
IOException - If some other kind of I/O error occurs.

open

public static Connection open(String name,
                              int mode,
                              boolean timeouts)
                       throws IOException
Create and open a Connection.

Parameters:
name - The URL for the connection
mode - The access mode
timeouts - A flag to indicate that the caller wants timeout exceptions
Returns:
A new Connection object
Throws:
IllegalArgumentException - If a parameter is invalid.
ConnectionNotFoundException - if the requested connection cannot be make, or the protocol type does not exist.
IOException - If some other kind of I/O error occurs.

openDataInputStream

public static DataInputStream openDataInputStream(String name)
                                           throws IOException
Create and open a connection input stream.

Parameters:
name - The URL for the connection.
Returns:
A DataInputStream.
Throws:
IllegalArgumentException - If a parameter is invalid.
ConnectionNotFoundException - If the connection cannot be found.
IOException - If some other kind of I/O error occurs.

openDataOutputStream

public static DataOutputStream openDataOutputStream(String name)
                                             throws IOException
Create and open a connection output stream.

Parameters:
name - The URL for the connection.
Returns:
A DataOutputStream.
Throws:
IllegalArgumentException - If a parameter is invalid.
ConnectionNotFoundException - If the connection cannot be found.
IOException - If some other kind of I/O error occurs.

openInputStream

public static InputStream openInputStream(String name)
                                   throws IOException
Create and open a connection input stream.

Parameters:
name - The URL for the connection.
Returns:
An InputStream.
Throws:
IllegalArgumentException - If a parameter is invalid.
ConnectionNotFoundException - If the connection cannot be found.
IOException - If some other kind of I/O error occurs.

openOutputStream

public static OutputStream openOutputStream(String name)
                                     throws IOException
Create and open a connection output stream.

Parameters:
name - The URL for the connection.
Returns:
An OutputStream.
Throws:
IllegalArgumentException - If a parameter is invalid.
ConnectionNotFoundException - If the connection cannot be found.
IOException - If some other kind of I/O error occurs.


Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries. Copyright (c) 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.

Portions of this document are under the following copyright:
Copyright © 2003 Nokia. All rights reserved.