SlideShare a Scribd company logo
- Arulkumar V
Assistant Professor, SECE
Java Stream & IO
What is Stream in java
12/19/20172
 A stream can be defined as a sequence of data.
There are two kinds of Streams −

InPutStream − The InputStream is used to read
data from a source.
 OutPutStream − The OutputStream is used for
writing data to a destination.
12/19/20173
Example
import java.io.*;
public class CopyFile {
public static void main(String args[]) throws IOException {
FileInputStream in = null;
FileOutputStream out = null;
try {
in = new FileInputStream("input.txt");
out = new FileOutputStream("output.txt");
int c;
while ((c = in.read()) != -1)
{
out.write(c); } }
finally {
if (in != null)
{ in.close(); } if (out != null) { out.close(); } } } }
Reading and Writing Files
12/19/20174
The java.lang.String class
implements Serializable, Comparable and CharSequence
interfaces.
12/19/20175
String methods
12/19/20176
 Java String class provides a lot of
methods to perform operations on string
such as
 compare(), concat(), equals(), split(),
length(), replace(), compareTo(), intern(),
substring() etc.

String Example
12/19/20177
public class StringExample{
public static void main(String args[]){
String s1="java";//creating string by java string literal
char ch[]={'s','t','r','i','n','g','s'};
String s2=new String(ch);//converting char array to string
String s3=new String("example");//creating java string by
new keyword
System.out.println(s1);
System.out.println(s2);
System.out.println(s3);
}}
String methods ex
12/19/20178
public class CharAtExample{
public static void main(String args[]){
String name="javatpoint";
char ch=name.charAt(4);//returns the char value at the 4th index
System.out.println(ch);
}}
public class CharAtExample{
public static void main(String args[]){
String name="javatpoint";
char ch=name.charAt(10);//returns the char value at the 10th
index
System.out.println(ch);
}}
12/19/20179
12/19/201710
Thank You

More Related Content

PPTX
Session 17 - Collections - Lists, Sets
PPTX
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
PPTX
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
PDF
Oshs_9_11_2015
PPTX
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
PPTX
Chapter 10.3
PPTX
Session 16 - Collections - Sorting, Comparing Basics
PPTX
9 Inputs & Outputs
Session 17 - Collections - Lists, Sets
Type Casting C# - Lec4 (Workshop on C# Programming: Learn to Build)
Data Type C# - Lec2 (Workshop on C# Programming: Learn to Build)
Oshs_9_11_2015
C# Basic - Lec1 (Workshop on C# Programming: Learn to Build)
Chapter 10.3
Session 16 - Collections - Sorting, Comparing Basics
9 Inputs & Outputs

What's hot (20)

PPTX
Session 20 - Collections - Maps
PDF
Java - File Input Output Concepts
PPTX
odoo 11.0 development (CRUD)
PPTX
Streams and Files
PPTX
PDF
DATA STRUCTURE
PPTX
File handling
PPT
File Input & Output
PPT
ASP.NET Session 7
PPT
Xml processing-by-asfak
PPS
Files & IO in Java
PPTX
Java file
PPT
Deletion of a Record from a File - K Karun
PPTX
32sql server
PPTX
Session 14 - Object Class
PPTX
Files and streams In Java
PPT
Input output streams
PPT
DOC
Session 20 - Collections - Maps
Java - File Input Output Concepts
odoo 11.0 development (CRUD)
Streams and Files
DATA STRUCTURE
File handling
File Input & Output
ASP.NET Session 7
Xml processing-by-asfak
Files & IO in Java
Java file
Deletion of a Record from a File - K Karun
32sql server
Session 14 - Object Class
Files and streams In Java
Input output streams
Ad

Similar to Streams&io (20)

PDF
Java I/o streams
PPTX
Basic of Javaio
PPTX
Files io
PDF
IO Streams, Serialization, de-serialization, autoboxing
PPTX
Input output files in java
PPTX
Java I/O
PDF
11_Str11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.eams.pdf
PDF
IOstreams hgjhsgfdjyggckhgckhjxfhbuvobunciu
PDF
What is java input and output stream?
PDF
What is java input and output stream?
PPTX
Understanding java streams
PPT
Java căn bản - Chapter12
PPT
Chapter 12 - File Input and Output
PDF
5. Ввод-вывод, доступ к файловой системе
PDF
Core Java Programming Language (JSE) : Chapter XI - Console I/O and File I/O
PPTX
File Input and output.pptx
PDF
File Handling in Java.pdf
PPT
Jedi Slides Intro2 Chapter12 Advanced Io Streams
PPTX
Java Tutorial Lab 6
Java I/o streams
Basic of Javaio
Files io
IO Streams, Serialization, de-serialization, autoboxing
Input output files in java
Java I/O
11_Str11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.11_Streams.eams.pdf
IOstreams hgjhsgfdjyggckhgckhjxfhbuvobunciu
What is java input and output stream?
What is java input and output stream?
Understanding java streams
Java căn bản - Chapter12
Chapter 12 - File Input and Output
5. Ввод-вывод, доступ к файловой системе
Core Java Programming Language (JSE) : Chapter XI - Console I/O and File I/O
File Input and output.pptx
File Handling in Java.pdf
Jedi Slides Intro2 Chapter12 Advanced Io Streams
Java Tutorial Lab 6
Ad

More from PhD Research Scholar (20)

PPTX
Quiz servlet
PPTX
servlet db connectivity
PPTX
2.java script dom
PPTX
1.java script
PPTX
Quiz javascript
PPTX
Thread&multithread
PPTX
PPTX
Interface in java
PPTX
Inner classes in java
PPTX
PPTX
Exception handling
PPTX
Abstract class
PPTX
7. tuples, set & dictionary
PPTX
PPTX
4. functions
Quiz servlet
servlet db connectivity
2.java script dom
1.java script
Quiz javascript
Thread&multithread
Interface in java
Inner classes in java
Exception handling
Abstract class
7. tuples, set & dictionary
4. functions

Recently uploaded (20)

PDF
Basic Mud Logging Guide for educational purpose
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Complications of Minimal Access Surgery at WLH
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Classroom Observation Tools for Teachers
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Pre independence Education in Inndia.pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Insiders guide to clinical Medicine.pdf
Basic Mud Logging Guide for educational purpose
Anesthesia in Laparoscopic Surgery in India
O5-L3 Freight Transport Ops (International) V1.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Microbial disease of the cardiovascular and lymphatic systems
VCE English Exam - Section C Student Revision Booklet
Complications of Minimal Access Surgery at WLH
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Classroom Observation Tools for Teachers
Final Presentation General Medicine 03-08-2024.pptx
Renaissance Architecture: A Journey from Faith to Humanism
Module 4: Burden of Disease Tutorial Slides S2 2025
Abdominal Access Techniques with Prof. Dr. R K Mishra
Pre independence Education in Inndia.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Insiders guide to clinical Medicine.pdf

Streams&io

  • 1. - Arulkumar V Assistant Professor, SECE Java Stream & IO
  • 2. What is Stream in java 12/19/20172  A stream can be defined as a sequence of data. There are two kinds of Streams −  InPutStream − The InputStream is used to read data from a source.  OutPutStream − The OutputStream is used for writing data to a destination.
  • 3. 12/19/20173 Example import java.io.*; public class CopyFile { public static void main(String args[]) throws IOException { FileInputStream in = null; FileOutputStream out = null; try { in = new FileInputStream("input.txt"); out = new FileOutputStream("output.txt"); int c; while ((c = in.read()) != -1) { out.write(c); } } finally { if (in != null) { in.close(); } if (out != null) { out.close(); } } } }
  • 4. Reading and Writing Files 12/19/20174
  • 5. The java.lang.String class implements Serializable, Comparable and CharSequence interfaces. 12/19/20175
  • 6. String methods 12/19/20176  Java String class provides a lot of methods to perform operations on string such as  compare(), concat(), equals(), split(), length(), replace(), compareTo(), intern(), substring() etc. 
  • 7. String Example 12/19/20177 public class StringExample{ public static void main(String args[]){ String s1="java";//creating string by java string literal char ch[]={'s','t','r','i','n','g','s'}; String s2=new String(ch);//converting char array to string String s3=new String("example");//creating java string by new keyword System.out.println(s1); System.out.println(s2); System.out.println(s3); }}
  • 8. String methods ex 12/19/20178 public class CharAtExample{ public static void main(String args[]){ String name="javatpoint"; char ch=name.charAt(4);//returns the char value at the 4th index System.out.println(ch); }} public class CharAtExample{ public static void main(String args[]){ String name="javatpoint"; char ch=name.charAt(10);//returns the char value at the 10th index System.out.println(ch); }}