#ff0000 7  2005 . - #000655    CLDC 
#def   ,  Connected Limited Device Configuration (CLDC) 
  ,    .    ,        , USB,  ,    -  .        ,   Generic Connection Framework (GCF).
GCF    ,   ,  ,   .      javax.microedition.io.      ,           .     GCF.            JDBC.
     (HTTP, ,     ),      Connector. ,     open(),   URI (   -    URL)   Connection -       .     HTTP :

----
import javax.microedition.io.*;

ContentConnection conn = (ContentConnection) Connector.open("http://www.yahoo.com" );
----

     :

___
import javax.microedition.io.*;

InputConnection conn =
    (InputConnection) Connector.open(
      "file:/autoexec.bat", Connector.READ );
___

     open(),           .

       ,    openInputStream, openDataInputStream, openOutputStream  openDataOutputStream,   c  .

URI   :

<protocol>:<address>;<parameters>

 protocol   , address -  , parameters -  . Protocol     ,  "http", "mailto", "ftp".        .  Connector   protocol,      ,   URI,       Connection.
 ,  CLDC     GCF      ,   -  . ,   CLDC ,     . ,  MIDP   HTTP .       .  CLDC   Sun,    ,  "datagram", "socket"  "file".     ,       ,  ,  . 
  ,  GCF     Connection.       :     close().
 InputConnection     .         .    : InputStream()  DataInputStream().     :

---
import java.io.*;
import javax.microedition.io.*;

public class TestInput {

    public static void main( String args[] ) {
        try {
            String uri = "file:c:/autoexec.bat";
            InputConnection conn = (InputConnection)
                     Connector.open( uri,
                        Connector.READ );
            InputStream in = conn.openInputStream();
            int ch;

            conn.close(); //    !

            System.out.println( "Contents of [" + uri +
                                                 "]" );

            while( ( ch = in.read() ) != -1 ){
                System.out.print( (char) ch );
            }

            in.close();
        }
        catch( ConnectionNotFoundException e ){
            System.out.println( "File could not be
                                         found!" );
        }
        catch( IOException e ){
        System.out.println( e.toString() );
        }

        System.exit( 0 );
    }
}
---
     ,      "file". (  ,           .)     ,  URI  : "file::".  URI       WINDOWs.      Unix/Linux,   "file:".

         .       ,
    . 
  .       MIDlet (    MIDP ),      System.exit   .     MIDlet.notify.Destroyed.
       OutputConnection:

---
import java.io.*;
import javax.microedition.io.*;

public class TestOutput {

    public static void main( String[] args ){
        try {
            String uri = "file:c:/hah.txt;append=true";
            OutputConnection conn = (OutputConnection)
                     Connector.open( uri, Connector.WRITE );
            OutputStream out = conn.openOutputStream();
            PrintStream print = new PrintStream( out );

            conn.close(); //    !

            print.println( "Hah hah hah!" );

            out.close();
        }
        catch( ConnectionNotFoundException e ){
            System.out.println( "File could not be
                                      created!" );
        }
        catch( IOException e ){
            System.out.println( e.toString() );
        }

        System.exit( 0 );
    }
}
---

 ,      .      ,   ";append=true"  URI.
      (   ),   socket,     StreamConnection,    InputConnection  OutputConnection.     :

---
import java.io.*;
import javax.microedition.io.*;

public class TestInputOutput {

    public static void main( String[] args ){
        try {
            String uri =
            "socket://www.ericgiguere.com:80";
            StreamConnection conn = (StreamConnection)
                     Connector.open( uri );

            //  HTTP ...

            PrintStream out = new PrintStream(
                                conn.openOutputStream() );
            out.println( "GET /index.html HTTP/0.9\r\n" );
            out.flush();

            //   HTTP ...

            InputStream in = conn.openInputStream();
            int ch;


            while( ( ch = in.read() ) != -1 ){
                System.out.print( (char) ch );
            }

            in.close();
            out.close();
            conn.close();
        }
        catch( ConnectionNotFoundException e ){
            System.out.println( "Socket could not be
                                          opened" );
        }
        catch( IOException e ){
            System.out.println( e.toString() );
        }

        System.exit( 0 );
    }
}
---
  TestInputOutput    HTTP     GET .    .        ,   ContentConnection   "testhttp".       HTTP .     :
---
import java.io.*;
import javax.microedition.io.*;

public class TestHTTP {

    public static void main( String[] args ){
        try {
            String uri =
              "testhttp://www.ericgiguere.com/index.html";
            ContentConnection conn = (ContentConnection)
               Connector.open( uri );

            InputStream in = conn.openInputStream();
            int ch;

            System.out.println( "Content type is "
                               + conn.getType() );

            while( ( ch = in.read() ) != -1 ){
                System.out.print( (char) ch );
            }

            in.close();
            conn.close();
        }
        catch( ConnectionNotFoundException e ){
            System.out.println(
                   "URI could not be opened" );
        }
        catch( IOException e ){
            System.out.println( e.toString() );
        }

        System.exit( 0 );
    }
}
---

 ContentConnection  StreamConnection     ,    HTTP : getType, getEncoding  getLength.    ContentConnection   .  MIDP      HttpConnection,     HTTP .      " HTTP   MIDP".
      .  StreamConnectionNotifier          acceptAndOpen.       .    StreamConnection,        "serversocket" .
   DatagramConnection.       . DatagramConnection    java.net.DatagramSocket J2SE 