SlideShare uma empresa Scribd logo
1 de 23
J2ME I/O Classes

                     Rohan Chandane
             rohan.chandane@indiatimes.com



This notes are created by me, Rohan Chandane as learning material while pursuing MSc (CA) from SICSR. (CC) 2005-07
Basics
   CLDC-MIDP package for input/output
       java.io;
       javax.microedition.io;
   Contain classes
       For input/output (I/O)
       For networking I/O
   Contain Interface, (which MIDP adds)
       Including HttpConnection
               Defines methods and constants for HTTP connection
javax.microedition.io Package
   Networking support using
       The Generic Connection Framework
       Includes
           New socket
           UDP
           Serial connection types
           Secure connection types
           Push functionality
The Generic Connection
Framework (GCF)
   Class hierarchy of the Generic
    Connection Framework




     GCF is a set of interfaces defined within the javax.microedition.io package
Continued…
   Connection Interface is at root
   Supported by
       datagram (packet)
       stream connections
            Input stream
            Output stream
Interfaces
   7 main Interfaces
       Connection
       InputConnection
       OutputConnection
       DatagramConnection
       StreamConncetion
       StreamConnectionNotifier
       ContentConnection
In brief - Interfaces
   The Connection interface
       Most basic connection type
       It can only be opened and closed
   The InputConnection interface
       Representation of stream based input
        connection
   The OutputConnection interface
       Representation of stream based output
        connection
Continued…
   The DatagramConnection interface
       For sending and receiving UDP packet
        oriented data
       Following address scheme is used
            {protocol}://[{host}]:[{port}]
       Example
            A datagram connection for accepting datagrams
             datagram://:1234
            A datagram connection for sending to a server:
             datagram://123.456.789.12:1234
Continued…
   The StreamConncetion interface
       A two way stream connection to a device
       Include both input and output connection
       Combines the input and output connections
   The StreamConncetionNotifier interface
       Waits for a connection to be established
       Returns a StreamConnection on which a
        communication link has been established.
Continued…
   The ContentConnection interface
       Subinterface of StreamConnection
       Provides access to some of the basic meta
        data information provided by HTTP
        connections
Classes
   Connector class is used to open every
    type of connection in GCF
   open() method
       Connector Class method
       All connections are created using this static
        method
       Following syntax used
            Connector.Open(quot;protocol:address;parametersquot;);
Continued…
   Few examples
       HTTP Connection
              Connector.open(quot;http://java.sun.com/developerquot;);
       Datagram Connection
              Connector.open(quot;datagram://address:port#quot;);
       Communicate with a Port
              Connector.open(quot;comm:0;baudrate=9600');
       Open Files
              Connector.open(quot;file:/myFile.txtquot;);
       Socket Connection
              Connector.open(quot;socket://localhost:9000quot;);
Continued…
   CGF has 7 methods to open Connection
Connector (public class Connector)
  public static Connection open(String name)
  public static Connection open(String name)
  public static Connection open(String name, int mode, boolean timeouts)
  public static DataInputStream openDataInputStream(String name)
  public static DataOutputStream openDataOutputStream(String name)
  public static InputStream openInputStream(String name)
  public static OutputStream openOutputStream(String name)
Examples
// create ContentConnection
String url = quot;http://www.mysite.com/mypage.jspquot;
ContentConnection conn = (ContentConnection)Connector.open(url);

// with connection open input stream
InputStream is = conn.openInputStream();
Read Image from server
// create ContentConnection
String url = quot;http://www.mysite.com/mypage.jspquot;
ContentConnection conn = (ContentConnection)Connector.open(url);

// with connection open input stream
InputStream is = conn.openInputStream();

// ContentConnection include lengh method
int lenght = (int) Conn.getLength();
if(length != -1)
{
          byte imagebyte[] = new byte[length];
          is.read(imagebyte);
}
HTTP support in MIDP
   GCF class support for HTTP
Continued…
// Create a HttpConnection
String url = quot;http://www.mysite.com/mypage.jspquot;
HttpConnection conn = (HttpConnection)Connector.open(url)

// with connection open a input stream reader (java.io package class)
InputSteamReader doc = new InputStreamReader(conn.openInputStream());



// Create a Secure Http Connection
String url = quot;http://www.mysite.com/mypage.jspquot;
HttpsConnection conn = (HttpsConnection)Connector.open(url)

// with connection open a input stream reader (java.io package class)
InputSteamReader doc = new InputStreamReader(conn.openInputStream());
I/O Classes in J2ME
   I/O Class Library Package
       java.io
   11 Classes are mainly used
       InputStream
            Base class for inputstream
            To obtain input stream from source
            Input stream need to wait till web server
             delivers the data from web page
Continued…
    ByteArrayInputStream
        Input stream that reads data from the internal
         byte array
    DataInputStream
        Stream that enters data into primitive Java data
         type
    InputStreamReader
        Stream that reads data as text characters
Continued…
    Reader
        An abstract class that is used to enter stream
         of character
    OutputStream
        The base class for output stream
    ByteArrayOutputStream
        Output stream which write data into internal
         byte array
Continued…
    DataOutputStram
         Stream that holds data written for primitive
          data type
    OutputStreamReader
         Stream that writes data as text characters
    Writer
         An abstract class that is used to write streams
          of character
    PrintStream
         Output stream that enables the writing of
          primitive data types
InputStream
   Methods
       read()
            Reads data as byte integer, Returns -1 if end of
             input stream
       read(byte b[])
            Takes array of byte as input and store it in an
             array
       read(byte b[], int offset, int length)
            Accept array of byte, offset is exact position in
             array where we want to store input data,
             length is max number of byte to be read
OutputStream
   Methods
       write(int n)
            Used to write single byte of data
       write(byte b[])
            Allow to write array of bytes
       write(byte b[], int offset, int length)
            Accept array of byte, offset is exact position in
             array where we want to write data, length is
             max number of byte to be written

Mais conteúdo relacionado

Mais procurados

Session 24 - JDBC, Intro to Enterprise Java
Session 24 - JDBC, Intro to Enterprise JavaSession 24 - JDBC, Intro to Enterprise Java
Session 24 - JDBC, Intro to Enterprise JavaPawanMM
 
Introduction to Thrift
Introduction to ThriftIntroduction to Thrift
Introduction to ThriftDvir Volk
 
Jsp client request
Jsp   client requestJsp   client request
Jsp client requestchauhankapil
 
Java networking programs - theory
Java networking programs - theoryJava networking programs - theory
Java networking programs - theoryMukesh Tekwani
 
Teach your (micro)services talk Protocol Buffers with gRPC.
Teach your (micro)services talk Protocol Buffers with gRPC.Teach your (micro)services talk Protocol Buffers with gRPC.
Teach your (micro)services talk Protocol Buffers with gRPC.Mihai Iachimovschi
 
HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009jarfield
 
Thrift vs Protocol Buffers vs Avro - Biased Comparison
Thrift vs Protocol Buffers vs Avro - Biased ComparisonThrift vs Protocol Buffers vs Avro - Biased Comparison
Thrift vs Protocol Buffers vs Avro - Biased ComparisonIgor Anishchenko
 
Apache thrift-RPC service cross languages
Apache thrift-RPC service cross languagesApache thrift-RPC service cross languages
Apache thrift-RPC service cross languagesJimmy Lai
 
Groovy DSLs, from Beginner to Expert - Guillaume Laforge and Paul King - Spri...
Groovy DSLs, from Beginner to Expert - Guillaume Laforge and Paul King - Spri...Groovy DSLs, from Beginner to Expert - Guillaume Laforge and Paul King - Spri...
Groovy DSLs, from Beginner to Expert - Guillaume Laforge and Paul King - Spri...Guillaume Laforge
 

Mais procurados (16)

Protocol Buffers
Protocol BuffersProtocol Buffers
Protocol Buffers
 
Session 24 - JDBC, Intro to Enterprise Java
Session 24 - JDBC, Intro to Enterprise JavaSession 24 - JDBC, Intro to Enterprise Java
Session 24 - JDBC, Intro to Enterprise Java
 
Protocol Buffers
Protocol BuffersProtocol Buffers
Protocol Buffers
 
Jug java7
Jug java7Jug java7
Jug java7
 
HTTP
HTTPHTTP
HTTP
 
Introduction to Thrift
Introduction to ThriftIntroduction to Thrift
Introduction to Thrift
 
Jsp client request
Jsp   client requestJsp   client request
Jsp client request
 
Java networking programs - theory
Java networking programs - theoryJava networking programs - theory
Java networking programs - theory
 
java networking
 java networking java networking
java networking
 
Teach your (micro)services talk Protocol Buffers with gRPC.
Teach your (micro)services talk Protocol Buffers with gRPC.Teach your (micro)services talk Protocol Buffers with gRPC.
Teach your (micro)services talk Protocol Buffers with gRPC.
 
HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009
 
Networking in Java
Networking in JavaNetworking in Java
Networking in Java
 
Thrift vs Protocol Buffers vs Avro - Biased Comparison
Thrift vs Protocol Buffers vs Avro - Biased ComparisonThrift vs Protocol Buffers vs Avro - Biased Comparison
Thrift vs Protocol Buffers vs Avro - Biased Comparison
 
Apache thrift-RPC service cross languages
Apache thrift-RPC service cross languagesApache thrift-RPC service cross languages
Apache thrift-RPC service cross languages
 
Groovy DSLs, from Beginner to Expert - Guillaume Laforge and Paul King - Spri...
Groovy DSLs, from Beginner to Expert - Guillaume Laforge and Paul King - Spri...Groovy DSLs, from Beginner to Expert - Guillaume Laforge and Paul King - Spri...
Groovy DSLs, from Beginner to Expert - Guillaume Laforge and Paul King - Spri...
 
Google Protocol Buffers
Google Protocol BuffersGoogle Protocol Buffers
Google Protocol Buffers
 

Destaque

13. Computer Systems Input And Output Architecture
13. Computer Systems   Input And  Output Architecture13. Computer Systems   Input And  Output Architecture
13. Computer Systems Input And Output ArchitectureNew Era University
 
Input Output Organization
Input Output OrganizationInput Output Organization
Input Output OrganizationKamal Acharya
 
Computer architecture
Computer architectureComputer architecture
Computer architectureRishabha Garg
 
Input Output - Computer Architecture
Input Output - Computer ArchitectureInput Output - Computer Architecture
Input Output - Computer ArchitectureMaruf Abdullah (Rion)
 
Input Output Interfaces
Input Output InterfacesInput Output Interfaces
Input Output InterfacesDarling Jemima
 

Destaque (7)

Input output interface
Input output interfaceInput output interface
Input output interface
 
13. Computer Systems Input And Output Architecture
13. Computer Systems   Input And  Output Architecture13. Computer Systems   Input And  Output Architecture
13. Computer Systems Input And Output Architecture
 
Networking devices
Networking devicesNetworking devices
Networking devices
 
Input Output Organization
Input Output OrganizationInput Output Organization
Input Output Organization
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
 
Input Output - Computer Architecture
Input Output - Computer ArchitectureInput Output - Computer Architecture
Input Output - Computer Architecture
 
Input Output Interfaces
Input Output InterfacesInput Output Interfaces
Input Output Interfaces
 

Semelhante a J2ME IO Classes

CHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptxCHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptxSadhilAggarwal
 
1.26 File Input-Output in JAVA.pptx
1.26 File Input-Output in JAVA.pptx1.26 File Input-Output in JAVA.pptx
1.26 File Input-Output in JAVA.pptxYashrajMohrir
 
KScope14 Jython Scripting
KScope14 Jython ScriptingKScope14 Jython Scripting
KScope14 Jython ScriptingAlithya
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in JavaTushar B Kute
 
Developing real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and KafkaDeveloping real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and Kafkamarius_bogoevici
 
What's new in DWR version 3
What's new in DWR version 3What's new in DWR version 3
What's new in DWR version 3Joe Walker
 
Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Itzik Kotler
 
15network Programming Clients
15network Programming Clients15network Programming Clients
15network Programming ClientsAdil Jafri
 
Network Programming Clients
Network Programming ClientsNetwork Programming Clients
Network Programming ClientsAdil Jafri
 
Rapid Network Application Development with Apache MINA
Rapid Network Application Development with Apache MINARapid Network Application Development with Apache MINA
Rapid Network Application Development with Apache MINAtrustinlee
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaYevgeniy Brikman
 
[DSBW Spring 2009] Unit 02: Web Technologies (2/2)
[DSBW Spring 2009] Unit 02: Web Technologies (2/2)[DSBW Spring 2009] Unit 02: Web Technologies (2/2)
[DSBW Spring 2009] Unit 02: Web Technologies (2/2)Carles Farré
 
Network Programming in Java
Network Programming in JavaNetwork Programming in Java
Network Programming in JavaTushar B Kute
 
Lambdas & Streams
Lambdas & StreamsLambdas & Streams
Lambdas & StreamsC4Media
 
Networking.ppt(client/server, socket) uses in program
Networking.ppt(client/server, socket) uses in programNetworking.ppt(client/server, socket) uses in program
Networking.ppt(client/server, socket) uses in programgovindjha339843
 
Java- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionJava- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionMazenetsolution
 
Unit No 5 Files and Database Connectivity.pptx
Unit No 5 Files and Database Connectivity.pptxUnit No 5 Files and Database Connectivity.pptx
Unit No 5 Files and Database Connectivity.pptxDrYogeshDeshmukh1
 
Basic html5 and javascript
Basic html5 and javascriptBasic html5 and javascript
Basic html5 and javascriptwendy017
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in JavaTushar B Kute
 

Semelhante a J2ME IO Classes (20)

CHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptxCHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptx
 
1.26 File Input-Output in JAVA.pptx
1.26 File Input-Output in JAVA.pptx1.26 File Input-Output in JAVA.pptx
1.26 File Input-Output in JAVA.pptx
 
KScope14 Jython Scripting
KScope14 Jython ScriptingKScope14 Jython Scripting
KScope14 Jython Scripting
 
T2
T2T2
T2
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Developing real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and KafkaDeveloping real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and Kafka
 
What's new in DWR version 3
What's new in DWR version 3What's new in DWR version 3
What's new in DWR version 3
 
Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)
 
15network Programming Clients
15network Programming Clients15network Programming Clients
15network Programming Clients
 
Network Programming Clients
Network Programming ClientsNetwork Programming Clients
Network Programming Clients
 
Rapid Network Application Development with Apache MINA
Rapid Network Application Development with Apache MINARapid Network Application Development with Apache MINA
Rapid Network Application Development with Apache MINA
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
 
[DSBW Spring 2009] Unit 02: Web Technologies (2/2)
[DSBW Spring 2009] Unit 02: Web Technologies (2/2)[DSBW Spring 2009] Unit 02: Web Technologies (2/2)
[DSBW Spring 2009] Unit 02: Web Technologies (2/2)
 
Network Programming in Java
Network Programming in JavaNetwork Programming in Java
Network Programming in Java
 
Lambdas & Streams
Lambdas & StreamsLambdas & Streams
Lambdas & Streams
 
Networking.ppt(client/server, socket) uses in program
Networking.ppt(client/server, socket) uses in programNetworking.ppt(client/server, socket) uses in program
Networking.ppt(client/server, socket) uses in program
 
Java- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionJava- JDBC- Mazenet Solution
Java- JDBC- Mazenet Solution
 
Unit No 5 Files and Database Connectivity.pptx
Unit No 5 Files and Database Connectivity.pptxUnit No 5 Files and Database Connectivity.pptx
Unit No 5 Files and Database Connectivity.pptx
 
Basic html5 and javascript
Basic html5 and javascriptBasic html5 and javascript
Basic html5 and javascript
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 

Mais de Rohan Chandane

Agile Maturity Model, Certified Scrum Master!
Agile Maturity Model, Certified Scrum Master!Agile Maturity Model, Certified Scrum Master!
Agile Maturity Model, Certified Scrum Master!Rohan Chandane
 
Agile & Scrum, Certified Scrum Master! Crash Course
Agile & Scrum,  Certified Scrum Master! Crash CourseAgile & Scrum,  Certified Scrum Master! Crash Course
Agile & Scrum, Certified Scrum Master! Crash CourseRohan Chandane
 
An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications Rohan Chandane
 
Agile :what i learnt so far
Agile :what i learnt so farAgile :what i learnt so far
Agile :what i learnt so farRohan Chandane
 
Sencha / ExtJS : Object Oriented JavaScript
Sencha / ExtJS : Object Oriented JavaScriptSencha / ExtJS : Object Oriented JavaScript
Sencha / ExtJS : Object Oriented JavaScriptRohan Chandane
 
TIBCO General Interface - CSS Guide
TIBCO General Interface - CSS GuideTIBCO General Interface - CSS Guide
TIBCO General Interface - CSS GuideRohan Chandane
 
Blogger's Park Presentation (Blogging)
Blogger's Park Presentation (Blogging)Blogger's Park Presentation (Blogging)
Blogger's Park Presentation (Blogging)Rohan Chandane
 
Java2 MicroEdition-J2ME
Java2 MicroEdition-J2MEJava2 MicroEdition-J2ME
Java2 MicroEdition-J2MERohan Chandane
 

Mais de Rohan Chandane (13)

Agile Maturity Model, Certified Scrum Master!
Agile Maturity Model, Certified Scrum Master!Agile Maturity Model, Certified Scrum Master!
Agile Maturity Model, Certified Scrum Master!
 
Agile & Scrum, Certified Scrum Master! Crash Course
Agile & Scrum,  Certified Scrum Master! Crash CourseAgile & Scrum,  Certified Scrum Master! Crash Course
Agile & Scrum, Certified Scrum Master! Crash Course
 
An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications
 
Agile :what i learnt so far
Agile :what i learnt so farAgile :what i learnt so far
Agile :what i learnt so far
 
Backbone js
Backbone jsBackbone js
Backbone js
 
Node js
Node jsNode js
Node js
 
Sencha / ExtJS : Object Oriented JavaScript
Sencha / ExtJS : Object Oriented JavaScriptSencha / ExtJS : Object Oriented JavaScript
Sencha / ExtJS : Object Oriented JavaScript
 
TIBCO General Interface - CSS Guide
TIBCO General Interface - CSS GuideTIBCO General Interface - CSS Guide
TIBCO General Interface - CSS Guide
 
Blogger's Park Presentation (Blogging)
Blogger's Park Presentation (Blogging)Blogger's Park Presentation (Blogging)
Blogger's Park Presentation (Blogging)
 
J2ME GUI Programming
J2ME GUI ProgrammingJ2ME GUI Programming
J2ME GUI Programming
 
Parsing XML in J2ME
Parsing XML in J2MEParsing XML in J2ME
Parsing XML in J2ME
 
J2ME RMS
J2ME RMSJ2ME RMS
J2ME RMS
 
Java2 MicroEdition-J2ME
Java2 MicroEdition-J2MEJava2 MicroEdition-J2ME
Java2 MicroEdition-J2ME
 

Último

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 

Último (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 

J2ME IO Classes

  • 1. J2ME I/O Classes Rohan Chandane rohan.chandane@indiatimes.com This notes are created by me, Rohan Chandane as learning material while pursuing MSc (CA) from SICSR. (CC) 2005-07
  • 2. Basics  CLDC-MIDP package for input/output  java.io;  javax.microedition.io;  Contain classes  For input/output (I/O)  For networking I/O  Contain Interface, (which MIDP adds)  Including HttpConnection  Defines methods and constants for HTTP connection
  • 3. javax.microedition.io Package  Networking support using  The Generic Connection Framework  Includes  New socket  UDP  Serial connection types  Secure connection types  Push functionality
  • 4. The Generic Connection Framework (GCF)  Class hierarchy of the Generic Connection Framework GCF is a set of interfaces defined within the javax.microedition.io package
  • 5. Continued…  Connection Interface is at root  Supported by  datagram (packet)  stream connections  Input stream  Output stream
  • 6. Interfaces  7 main Interfaces  Connection  InputConnection  OutputConnection  DatagramConnection  StreamConncetion  StreamConnectionNotifier  ContentConnection
  • 7. In brief - Interfaces  The Connection interface  Most basic connection type  It can only be opened and closed  The InputConnection interface  Representation of stream based input connection  The OutputConnection interface  Representation of stream based output connection
  • 8. Continued…  The DatagramConnection interface  For sending and receiving UDP packet oriented data  Following address scheme is used  {protocol}://[{host}]:[{port}]  Example  A datagram connection for accepting datagrams datagram://:1234  A datagram connection for sending to a server: datagram://123.456.789.12:1234
  • 9. Continued…  The StreamConncetion interface  A two way stream connection to a device  Include both input and output connection  Combines the input and output connections  The StreamConncetionNotifier interface  Waits for a connection to be established  Returns a StreamConnection on which a communication link has been established.
  • 10. Continued…  The ContentConnection interface  Subinterface of StreamConnection  Provides access to some of the basic meta data information provided by HTTP connections
  • 11. Classes  Connector class is used to open every type of connection in GCF  open() method  Connector Class method  All connections are created using this static method  Following syntax used  Connector.Open(quot;protocol:address;parametersquot;);
  • 12. Continued…  Few examples  HTTP Connection  Connector.open(quot;http://java.sun.com/developerquot;);  Datagram Connection  Connector.open(quot;datagram://address:port#quot;);  Communicate with a Port  Connector.open(quot;comm:0;baudrate=9600');  Open Files  Connector.open(quot;file:/myFile.txtquot;);  Socket Connection  Connector.open(quot;socket://localhost:9000quot;);
  • 13. Continued…  CGF has 7 methods to open Connection Connector (public class Connector) public static Connection open(String name) public static Connection open(String name) public static Connection open(String name, int mode, boolean timeouts) public static DataInputStream openDataInputStream(String name) public static DataOutputStream openDataOutputStream(String name) public static InputStream openInputStream(String name) public static OutputStream openOutputStream(String name)
  • 14. Examples // create ContentConnection String url = quot;http://www.mysite.com/mypage.jspquot; ContentConnection conn = (ContentConnection)Connector.open(url); // with connection open input stream InputStream is = conn.openInputStream();
  • 15. Read Image from server // create ContentConnection String url = quot;http://www.mysite.com/mypage.jspquot; ContentConnection conn = (ContentConnection)Connector.open(url); // with connection open input stream InputStream is = conn.openInputStream(); // ContentConnection include lengh method int lenght = (int) Conn.getLength(); if(length != -1) { byte imagebyte[] = new byte[length]; is.read(imagebyte); }
  • 16. HTTP support in MIDP  GCF class support for HTTP
  • 17. Continued… // Create a HttpConnection String url = quot;http://www.mysite.com/mypage.jspquot; HttpConnection conn = (HttpConnection)Connector.open(url) // with connection open a input stream reader (java.io package class) InputSteamReader doc = new InputStreamReader(conn.openInputStream()); // Create a Secure Http Connection String url = quot;http://www.mysite.com/mypage.jspquot; HttpsConnection conn = (HttpsConnection)Connector.open(url) // with connection open a input stream reader (java.io package class) InputSteamReader doc = new InputStreamReader(conn.openInputStream());
  • 18. I/O Classes in J2ME  I/O Class Library Package  java.io  11 Classes are mainly used  InputStream  Base class for inputstream  To obtain input stream from source  Input stream need to wait till web server delivers the data from web page
  • 19. Continued…  ByteArrayInputStream  Input stream that reads data from the internal byte array  DataInputStream  Stream that enters data into primitive Java data type  InputStreamReader  Stream that reads data as text characters
  • 20. Continued…  Reader  An abstract class that is used to enter stream of character  OutputStream  The base class for output stream  ByteArrayOutputStream  Output stream which write data into internal byte array
  • 21. Continued…  DataOutputStram  Stream that holds data written for primitive data type  OutputStreamReader  Stream that writes data as text characters  Writer  An abstract class that is used to write streams of character  PrintStream  Output stream that enables the writing of primitive data types
  • 22. InputStream  Methods  read()  Reads data as byte integer, Returns -1 if end of input stream  read(byte b[])  Takes array of byte as input and store it in an array  read(byte b[], int offset, int length)  Accept array of byte, offset is exact position in array where we want to store input data, length is max number of byte to be read
  • 23. OutputStream  Methods  write(int n)  Used to write single byte of data  write(byte b[])  Allow to write array of bytes  write(byte b[], int offset, int length)  Accept array of byte, offset is exact position in array where we want to write data, length is max number of byte to be written