SlideShare a Scribd company logo
1 of 16
z
Ms.N.RUBA
Assistant Professor
Dept. of Computer Applications
Bon Secours College for Women, Thanjavur.
An overview of I/o stream
 A stream is an ordered sequence of bytes that has a SOURCE or DESTINATION.
 two methods for input and output
 System.in.read()
 System.out.println()
Java i/o
 Java .io package defines a collection of stgream classes that represent input and output
using
import java.io.*
 Streams are classified into two types
 1.character streams
 2.byte streams
 Java .io package provides two sets of hierarchies to handle character and streams
 inputStream and OutputStream classes
 Reader and Writer are operated on characters
Java i/o
Name of class description
Reader, Writer Supports read/write
inputStream and
OutputStream
Define methods
file Enable creating,deleting
and renaming
Random Access File Program to read /write
from/to any location
Reader and Writer class hierarchy
Byte streams
Byte streams
Working with i/o super classes
 Methods contained by Reader class for reading character arrays
 Methods contained by InputStream class for reaching array of bytes
Method description
Int read()
Int read(char cbuf[])
Int read(char cbuf[], int offset,int length)
Method description
Int read()
Int read(char cbuf[])
Int read(char cbuf[], int offset,int length)
Java i/o
 Java .io package defines a collection of stgream classes that represent input and output
using
import java.io.*
 Streams are classified into two types
 1.character streams
 2.byte streams
 Java .io package provides two sets of hierarchies to handle character and streams
 inputStream and OutputStream classes
 Reader and Writer are operated on characters
APPLETS
 Applet Programming
 Applets are small Java applications that can be accessed on an Internet server,
transported over Internet, and can be automatically installed and run as a part of a web
document.
 An Applet is a Java class that extends the java.applet.Applet class.
 An Applet class does not have any main() method.
 It is viewed using JVM. The JVM can use either a plug-in of the Web browser or a
separate runtime environment to run an applet application that is “appletviewer”.
 Applets are designed to be embedded within an HTML page.
 When a user views an HTML page that contains an applet, the code for the applet is
downloaded to the user's machine.
Life cycle of Applets

 Init( ) - Initialize a variable. Called when an applet begins execution. It is the first method
called for any applet
 Start( )- After the init( ) method the program should be started. Called by browser when an
applet should start() execution. It automatically calle init().
 Paint( ) -drawing, writing and color creation. The paint( ) method is called Each time your
applet’s output must be redrawn. Paint( ) is also Called when the applet begins execution.
This method has one Parameter of type Graphics. It contain the Graphics context, which
describes the graphics environment. This context is used whenever output to the applet.
 Stop( )-Halt of the running applet. Called by browser to suspend execution of the applet.
Once stopped an applet is restarted when the browser calls start().
 Destroy( ) -> terminated. Called by browser just before an applet is terminated.
 Repaint( ) call update method.
How Applets differ from applications
The applets and stand-alone applications are java programs, there are significant differences
between. Applets are not full-featured application program. They are usually written to accomplish a
small task or a component of a task.
They are usually designed for use on the internet, they impose certain limitations and restrictions in
their design. Applets do not use the main( ) method for initiating the execution of the code. Applets,
 when loaded, automatically call certain methods of Applet class to start and execute the applet
code.
 Unlike stand-alone applications, applets cannot be run independently. They are run from inside a
web page using a special feature known as HTML tag.
 Applets cannot read from or write to the files in the local computer. Applets cannot communicate
with other servers on the network.
 Applets cannot run any program form the local computer.
 Applets are restricted from using libraries from other languages such as c or c++.
Life cycle of Applets

 Init( ) - Initialize a variable. Called when an applet begins execution. It is the first method
called for any applet
 Start( )- After the init( ) method the program should be started. Called by browser when an
applet should start() execution. It automatically calle init().
 Paint( ) -drawing, writing and color creation. The paint( ) method is called Each time your
applet’s output must be redrawn. Paint( ) is also Called when the applet begins execution.
This method has one Parameter of type Graphics. It contain the Graphics context, which
describes the graphics environment. This context is used whenever output to the applet.
 Stop( )-Halt of the running applet. Called by browser to suspend execution of the applet.
Once stopped an applet is restarted when the browser calls start().
 Destroy( ) -> terminated. Called by browser just before an applet is terminated.
 Repaint( ) call update method.
HTML Applet tag
 The APPLET tag is used to start an applet from both an HTML(Hyper Text Markup
Language) document and from an applet viewer
 An applet viewer will execute each APPLET tag that if finds in a separate window, while web
browsers like Netscape Navigator, Internet Explorer, and HotJava will allow many applets on
a single page. So far, we have been using only a simplified form of the APPLET tag.
 The syntax for the standard APPLET tag is shown here. Bracketed items are optional.
<APPLET
[CODEBASE = codebase URL]
CODE = applet file
WIDTH = pixels HEIGHT = pixels
[ALIGN = alignment] >
[<PARAM NAME = Attribute Name VALUE = Attribute value> ] [<PARAM NAME = Attribute Name2
VALUE = attribute value> ]
</APPLET>

THE HTML APPLET TAG:
CODEBASE:
It is an optional attribute that specifies the base URL of the applet code, which is the directory that will be searched for the applet’s
executable class file. The HTML document’s URL directory is used as the CODEBASE if this attribute is not specified.
CODE:
It is a required attribute that gives the name of the file containing your applet’s compiled .class file. This file is relative to the code
base URL of the applet, which is the directory that the HTML file was in or the directory indicated by CODEBASE if set.
WIDTH AND HEIGHT:
WIDTH and HEIGHT are required attributes that give the size ( in pixels) of the applet display area.
ALIGN:
It is an optional attribute that specifies the alignment of the applet. This attributes is treated the same as the HTML IMG tag with these
possible values: LEFT, RIGHT, TOP, BOTTOM, MIDDLE, BASELINE, TEXTTOP, ABSMIDDLE, and ABSBOTTOM.
PARAM NAME AND VALUE:
The PARAM tag allows you to specify applet specific arguments in an HTML page.
Applets access their attributes with the getParameter( ) method.
HANDLING BROWSERS:
The best way to design your HTML page to deal with such browsers is to include HTML text and markup within your
<applet></applet> tags. If the applet tags are not recognized by your browser, you will see the alternate markup. If java is available, it
will consume all of the markup between the <applet></applet> tags and disregard the alternate markup.
z
Thank you

More Related Content

What's hot

Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
sotlsoc
 
6.applet programming in java
6.applet programming in java6.applet programming in java
6.applet programming in java
Deepak Sharma
 
Java applet basics
Java applet basicsJava applet basics
Java applet basics
Sunil Pandey
 
Basics of applets.53
Basics of applets.53Basics of applets.53
Basics of applets.53
myrajendra
 

What's hot (20)

27 applet programming
27  applet programming27  applet programming
27 applet programming
 
Java Applet
Java AppletJava Applet
Java Applet
 
Java applets
Java appletsJava applets
Java applets
 
Appletjava
AppletjavaAppletjava
Appletjava
 
Java
JavaJava
Java
 
JAVA APPLETS
JAVA APPLETSJAVA APPLETS
JAVA APPLETS
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programming
 
Chapter 2.1
Chapter 2.1Chapter 2.1
Chapter 2.1
 
6.applet programming in java
6.applet programming in java6.applet programming in java
6.applet programming in java
 
L18 applets
L18 appletsL18 applets
L18 applets
 
Java Programming- Introduction to Java Applet Programs
Java Programming- Introduction to Java Applet ProgramsJava Programming- Introduction to Java Applet Programs
Java Programming- Introduction to Java Applet Programs
 
Java applet basics
Java applet basicsJava applet basics
Java applet basics
 
Applet
AppletApplet
Applet
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programming
 
ITFT- Applet in java
ITFT- Applet in javaITFT- Applet in java
ITFT- Applet in java
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
 
Java: Java Applets
Java: Java AppletsJava: Java Applets
Java: Java Applets
 
java applets
java appletsjava applets
java applets
 
Basics of applets.53
Basics of applets.53Basics of applets.53
Basics of applets.53
 

Similar to Java files and io streams

Java basics notes
Java basics notesJava basics notes
Java basics notes
Nexus
 

Similar to Java files and io streams (20)

Unit 7 Java
Unit 7 JavaUnit 7 Java
Unit 7 Java
 
applet.pptx
applet.pptxapplet.pptx
applet.pptx
 
Applet &amp; graphics programming
Applet &amp; graphics programmingApplet &amp; graphics programming
Applet &amp; graphics programming
 
Smart material - Unit 3 (2).pdf
Smart material - Unit 3 (2).pdfSmart material - Unit 3 (2).pdf
Smart material - Unit 3 (2).pdf
 
Smart material - Unit 3 (1).pdf
Smart material - Unit 3 (1).pdfSmart material - Unit 3 (1).pdf
Smart material - Unit 3 (1).pdf
 
UNIT-1-AJAVA.pdf
UNIT-1-AJAVA.pdfUNIT-1-AJAVA.pdf
UNIT-1-AJAVA.pdf
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
3. applets
3. applets3. applets
3. applets
 
Basic java part_ii
Basic java part_iiBasic java part_ii
Basic java part_ii
 
Applet (1)
Applet (1)Applet (1)
Applet (1)
 
Java applet-basics
Java applet-basicsJava applet-basics
Java applet-basics
 
Java applet-basics
Java applet-basicsJava applet-basics
Java applet-basics
 
JavaAdvUnit-1.pptx
JavaAdvUnit-1.pptxJavaAdvUnit-1.pptx
JavaAdvUnit-1.pptx
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
Java applet
Java appletJava applet
Java applet
 
Lecture1 oopj
Lecture1 oopjLecture1 oopj
Lecture1 oopj
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
 

More from RubaNagarajan

More from RubaNagarajan (19)

Computer graphics-CRT.pptx
Computer graphics-CRT.pptxComputer graphics-CRT.pptx
Computer graphics-CRT.pptx
 
Matrix representation- CG.pptx
Matrix representation- CG.pptxMatrix representation- CG.pptx
Matrix representation- CG.pptx
 
Personality development.pptx
Personality development.pptxPersonality development.pptx
Personality development.pptx
 
TRANSFORMATION-CG.pptx
TRANSFORMATION-CG.pptxTRANSFORMATION-CG.pptx
TRANSFORMATION-CG.pptx
 
dda algorithm-cg.pptx
dda algorithm-cg.pptxdda algorithm-cg.pptx
dda algorithm-cg.pptx
 
line attributes.pptx
line attributes.pptxline attributes.pptx
line attributes.pptx
 
Java -Exception handlingunit-iv
Java -Exception handlingunit-ivJava -Exception handlingunit-iv
Java -Exception handlingunit-iv
 
Java Programming
Java Programming Java Programming
Java Programming
 
Features of java unit 1
Features of java unit 1Features of java unit 1
Features of java unit 1
 
Introduction to Java -unit-1
Introduction to Java -unit-1Introduction to Java -unit-1
Introduction to Java -unit-1
 
Constructors in C++
Constructors in C++Constructors in C++
Constructors in C++
 
Risks in cc
Risks in ccRisks in cc
Risks in cc
 
Dreamweaver
DreamweaverDreamweaver
Dreamweaver
 
Working principles of internet
Working principles of internetWorking principles of internet
Working principles of internet
 
Coreldraw
CoreldrawCoreldraw
Coreldraw
 
C programming
C programmingC programming
C programming
 
OPERATING SYSTEM
OPERATING SYSTEMOPERATING SYSTEM
OPERATING SYSTEM
 
Virtualization in cloud computing
Virtualization in cloud computingVirtualization in cloud computing
Virtualization in cloud computing
 
Cloud computing technology
Cloud computing technologyCloud computing technology
Cloud computing technology
 

Recently uploaded

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 

Recently uploaded (20)

Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 

Java files and io streams

  • 1. z Ms.N.RUBA Assistant Professor Dept. of Computer Applications Bon Secours College for Women, Thanjavur.
  • 2. An overview of I/o stream  A stream is an ordered sequence of bytes that has a SOURCE or DESTINATION.  two methods for input and output  System.in.read()  System.out.println()
  • 3. Java i/o  Java .io package defines a collection of stgream classes that represent input and output using import java.io.*  Streams are classified into two types  1.character streams  2.byte streams  Java .io package provides two sets of hierarchies to handle character and streams  inputStream and OutputStream classes  Reader and Writer are operated on characters
  • 4. Java i/o Name of class description Reader, Writer Supports read/write inputStream and OutputStream Define methods file Enable creating,deleting and renaming Random Access File Program to read /write from/to any location
  • 5. Reader and Writer class hierarchy
  • 8. Working with i/o super classes  Methods contained by Reader class for reading character arrays  Methods contained by InputStream class for reaching array of bytes Method description Int read() Int read(char cbuf[]) Int read(char cbuf[], int offset,int length) Method description Int read() Int read(char cbuf[]) Int read(char cbuf[], int offset,int length)
  • 9. Java i/o  Java .io package defines a collection of stgream classes that represent input and output using import java.io.*  Streams are classified into two types  1.character streams  2.byte streams  Java .io package provides two sets of hierarchies to handle character and streams  inputStream and OutputStream classes  Reader and Writer are operated on characters
  • 10. APPLETS  Applet Programming  Applets are small Java applications that can be accessed on an Internet server, transported over Internet, and can be automatically installed and run as a part of a web document.  An Applet is a Java class that extends the java.applet.Applet class.  An Applet class does not have any main() method.  It is viewed using JVM. The JVM can use either a plug-in of the Web browser or a separate runtime environment to run an applet application that is “appletviewer”.  Applets are designed to be embedded within an HTML page.  When a user views an HTML page that contains an applet, the code for the applet is downloaded to the user's machine.
  • 11. Life cycle of Applets   Init( ) - Initialize a variable. Called when an applet begins execution. It is the first method called for any applet  Start( )- After the init( ) method the program should be started. Called by browser when an applet should start() execution. It automatically calle init().  Paint( ) -drawing, writing and color creation. The paint( ) method is called Each time your applet’s output must be redrawn. Paint( ) is also Called when the applet begins execution. This method has one Parameter of type Graphics. It contain the Graphics context, which describes the graphics environment. This context is used whenever output to the applet.  Stop( )-Halt of the running applet. Called by browser to suspend execution of the applet. Once stopped an applet is restarted when the browser calls start().  Destroy( ) -> terminated. Called by browser just before an applet is terminated.  Repaint( ) call update method.
  • 12. How Applets differ from applications The applets and stand-alone applications are java programs, there are significant differences between. Applets are not full-featured application program. They are usually written to accomplish a small task or a component of a task. They are usually designed for use on the internet, they impose certain limitations and restrictions in their design. Applets do not use the main( ) method for initiating the execution of the code. Applets,  when loaded, automatically call certain methods of Applet class to start and execute the applet code.  Unlike stand-alone applications, applets cannot be run independently. They are run from inside a web page using a special feature known as HTML tag.  Applets cannot read from or write to the files in the local computer. Applets cannot communicate with other servers on the network.  Applets cannot run any program form the local computer.  Applets are restricted from using libraries from other languages such as c or c++.
  • 13. Life cycle of Applets   Init( ) - Initialize a variable. Called when an applet begins execution. It is the first method called for any applet  Start( )- After the init( ) method the program should be started. Called by browser when an applet should start() execution. It automatically calle init().  Paint( ) -drawing, writing and color creation. The paint( ) method is called Each time your applet’s output must be redrawn. Paint( ) is also Called when the applet begins execution. This method has one Parameter of type Graphics. It contain the Graphics context, which describes the graphics environment. This context is used whenever output to the applet.  Stop( )-Halt of the running applet. Called by browser to suspend execution of the applet. Once stopped an applet is restarted when the browser calls start().  Destroy( ) -> terminated. Called by browser just before an applet is terminated.  Repaint( ) call update method.
  • 14. HTML Applet tag  The APPLET tag is used to start an applet from both an HTML(Hyper Text Markup Language) document and from an applet viewer  An applet viewer will execute each APPLET tag that if finds in a separate window, while web browsers like Netscape Navigator, Internet Explorer, and HotJava will allow many applets on a single page. So far, we have been using only a simplified form of the APPLET tag.  The syntax for the standard APPLET tag is shown here. Bracketed items are optional. <APPLET [CODEBASE = codebase URL] CODE = applet file WIDTH = pixels HEIGHT = pixels [ALIGN = alignment] > [<PARAM NAME = Attribute Name VALUE = Attribute value> ] [<PARAM NAME = Attribute Name2 VALUE = attribute value> ] </APPLET> 
  • 15. THE HTML APPLET TAG: CODEBASE: It is an optional attribute that specifies the base URL of the applet code, which is the directory that will be searched for the applet’s executable class file. The HTML document’s URL directory is used as the CODEBASE if this attribute is not specified. CODE: It is a required attribute that gives the name of the file containing your applet’s compiled .class file. This file is relative to the code base URL of the applet, which is the directory that the HTML file was in or the directory indicated by CODEBASE if set. WIDTH AND HEIGHT: WIDTH and HEIGHT are required attributes that give the size ( in pixels) of the applet display area. ALIGN: It is an optional attribute that specifies the alignment of the applet. This attributes is treated the same as the HTML IMG tag with these possible values: LEFT, RIGHT, TOP, BOTTOM, MIDDLE, BASELINE, TEXTTOP, ABSMIDDLE, and ABSBOTTOM. PARAM NAME AND VALUE: The PARAM tag allows you to specify applet specific arguments in an HTML page. Applets access their attributes with the getParameter( ) method. HANDLING BROWSERS: The best way to design your HTML page to deal with such browsers is to include HTML text and markup within your <applet></applet> tags. If the applet tags are not recognized by your browser, you will see the alternate markup. If java is available, it will consume all of the markup between the <applet></applet> tags and disregard the alternate markup.