SlideShare a Scribd company logo
File IO in Java

       Prof. AshishSingh Bhatia, ast.bhatia@gmail.com,
     ashish@asbspace.in, Web: asbspace.in, M:9879009551


                                 September 21, 2012




Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   1
AGENDA
Overview of IO Classes
OutputStream of IO
InputStream of IO
Writer of IO
Reader of IO
Methods of OutputStream Class
Methods of Writer Class
Methods of Writer Class Extra
Methods of InputStream Class
Methods of Reader Class
InputStream Usage
OutputStream Usage
Bridge Classes
OutputStreamWriter
InputStream Reader
FileInput and FileOutput Stream
  Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   2
Overview of IO Classes




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   3
OutputStream of IO




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   4
InputStream of IO




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   5
Writer of IO




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   6
Reader of IO




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   7
Methods of OutputStream Class

       public void write(int b)
       Writes a single byte to an output stream. Why we need int as
       argument?




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   8
Methods of OutputStream Class

       public void write(int b)
       Writes a single byte to an output stream. Why we need int as
       argument?
       public void write(byte[] b)
       Writes complete byte array in to an outputstream.




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   9
Methods of OutputStream Class

       public void write(int b)
       Writes a single byte to an output stream. Why we need int as
       argument?
       public void write(byte[] b)
       Writes complete byte array in to an outputstream.
       public void write(byte[] b, int offset, int len)
       Write a subrange from offset to specified length[number of
       bytes].




    Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   10
Methods of OutputStream Class

       public void write(int b)
       Writes a single byte to an output stream. Why we need int as
       argument?
       public void write(byte[] b)
       Writes complete byte array in to an outputstream.
       public void write(byte[] b, int offset, int len)
       Write a subrange from offset to specified length[number of
       bytes].
       public void flush()
       Flushes the output buffer. Ensures the contents are written to
       the destination.




    Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   11
Methods of OutputStream Class

       public void write(int b)
       Writes a single byte to an output stream. Why we need int as
       argument?
       public void write(byte[] b)
       Writes complete byte array in to an outputstream.
       public void write(byte[] b, int offset, int len)
       Write a subrange from offset to specified length[number of
       bytes].
       public void flush()
       Flushes the output buffer. Ensures the contents are written to
       the destination.
       public void close()
       Closes the outputstream. Further write will generate
       IOException
    Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   12
Methods of Writer Class


        public void write(int ch)
        Writes a single character to an output stream. Why we need
        int as argument?




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   13
Methods of Writer Class


        public void write(int ch)
        Writes a single character to an output stream. Why we need
        int as argument?
        public void write(char[] ch)
        Writes complete character array in to an outputstream.




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   14
Methods of Writer Class


        public void write(int ch)
        Writes a single character to an output stream. Why we need
        int as argument?
        public void write(char[] ch)
        Writes complete character array in to an outputstream.
        public void write(char[] b, int offset, int len)
        Write a subrange from offset to specified length[number of
        character].




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   15
Methods of Writer Class


        public void write(int ch)
        Writes a single character to an output stream. Why we need
        int as argument?
        public void write(char[] ch)
        Writes complete character array in to an outputstream.
        public void write(char[] b, int offset, int len)
        Write a subrange from offset to specified length[number of
        character].
        public void flush()
        Flushes the output buffer. Ensures the contents are written to
        the destination.




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   16
Methods of Writer Class


        public void write(int ch)
        Writes a single character to an output stream. Why we need
        int as argument?
        public void write(char[] ch)
        Writes complete character array in to an outputstream.
        public void write(char[] b, int offset, int len)
        Write a subrange from offset to specified length[number of
        character].
        public void flush()
        Flushes the output buffer. Ensures the contents are written to
        the destination.
        public void close()
        Closes the writer. Further write will generate IOException

     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   17
Methods of Writer Class Extra




        String is a sequence of Character.
        public void write(String s)




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   18
Methods of Writer Class Extra




        String is a sequence of Character.
        public void write(String s)
        public void write(String s, int offset, int len)




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   19
Methods of Writer Class Extra




        String is a sequence of Character.
        public void write(String s)
        public void write(String s, int offset, int len)
        public void append(char ch)




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   20
Methods of Writer Class Extra




        String is a sequence of Character.
        public void write(String s)
        public void write(String s, int offset, int len)
        public void append(char ch)
        public void append(CharSequence cs)




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   21
Methods of Writer Class Extra




        String is a sequence of Character.
        public void write(String s)
        public void write(String s, int offset, int len)
        public void append(char ch)
        public void append(CharSequence cs)
        public void append(CharSequence cs, int offset,
        int len)




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   22
Methods of InputStream Class
        public int read()
        Read the integer representation of the next available byte of
        input. Returns -1 when the end of file is encountered.




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   23
Methods of InputStream Class
        public int read()
        Read the integer representation of the next available byte of
        input. Returns -1 when the end of file is encountered.
        public int read(byte[] b)
        Attempt to read up to b.length bytes in the the b array.
        Returns the number of actual bytes read. -1 is returned when
        the end of file is encountered.




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   24
Methods of InputStream Class
        public int read()
        Read the integer representation of the next available byte of
        input. Returns -1 when the end of file is encountered.
        public int read(byte[] b)
        Attempt to read up to b.length bytes in the the b array.
        Returns the number of actual bytes read. -1 is returned when
        the end of file is encountered.
        public int read(byte[] b, int offset, int len)




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   25
Methods of InputStream Class
        public int read()
        Read the integer representation of the next available byte of
        input. Returns -1 when the end of file is encountered.
        public int read(byte[] b)
        Attempt to read up to b.length bytes in the the b array.
        Returns the number of actual bytes read. -1 is returned when
        the end of file is encountered.
        public int read(byte[] b, int offset, int len)
        public long skip(long count)
        count indicates number of bytes to be skipped and return the
        number of byte skipped or -1 in case of end of file.




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   26
Methods of InputStream Class
        public int read()
        Read the integer representation of the next available byte of
        input. Returns -1 when the end of file is encountered.
        public int read(byte[] b)
        Attempt to read up to b.length bytes in the the b array.
        Returns the number of actual bytes read. -1 is returned when
        the end of file is encountered.
        public int read(byte[] b, int offset, int len)
        public long skip(long count)
        count indicates number of bytes to be skipped and return the
        number of byte skipped or -1 in case of end of file.
        public int available()
        Number of bytes available for reading.




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   27
Methods of InputStream Class
        public int read()
        Read the integer representation of the next available byte of
        input. Returns -1 when the end of file is encountered.
        public int read(byte[] b)
        Attempt to read up to b.length bytes in the the b array.
        Returns the number of actual bytes read. -1 is returned when
        the end of file is encountered.
        public int read(byte[] b, int offset, int len)
        public long skip(long count)
        count indicates number of bytes to be skipped and return the
        number of byte skipped or -1 in case of end of file.
        public int available()
        Number of bytes available for reading.
        public void mark(int readlimit)



     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   28
Methods of InputStream Class
        public int read()
        Read the integer representation of the next available byte of
        input. Returns -1 when the end of file is encountered.
        public int read(byte[] b)
        Attempt to read up to b.length bytes in the the b array.
        Returns the number of actual bytes read. -1 is returned when
        the end of file is encountered.
        public int read(byte[] b, int offset, int len)
        public long skip(long count)
        count indicates number of bytes to be skipped and return the
        number of byte skipped or -1 in case of end of file.
        public int available()
        Number of bytes available for reading.
        public void mark(int readlimit)
        public void reset()

     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   29
Methods of InputStream Class
        public int read()
        Read the integer representation of the next available byte of
        input. Returns -1 when the end of file is encountered.
        public int read(byte[] b)
        Attempt to read up to b.length bytes in the the b array.
        Returns the number of actual bytes read. -1 is returned when
        the end of file is encountered.
        public int read(byte[] b, int offset, int len)
        public long skip(long count)
        count indicates number of bytes to be skipped and return the
        number of byte skipped or -1 in case of end of file.
        public int available()
        Number of bytes available for reading.
        public void mark(int readlimit)
        public void reset()
        public boolean markSupported()
     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   30
Methods of InputStream Class
        public int read()
        Read the integer representation of the next available byte of
        input. Returns -1 when the end of file is encountered.
        public int read(byte[] b)
        Attempt to read up to b.length bytes in the the b array.
        Returns the number of actual bytes read. -1 is returned when
        the end of file is encountered.
        public int read(byte[] b, int offset, int len)
        public long skip(long count)
        count indicates number of bytes to be skipped and return the
        number of byte skipped or -1 in case of end of file.
        public int available()
        Number of bytes available for reading.
        public void mark(int readlimit)
        public void reset()
        public boolean markSupported()
        public void close()
     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 31
Methods of Reader Class



        public int read()




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   32
Methods of Reader Class



        public int read()
        public int read(char[] b)




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   33
Methods of Reader Class



        public int read()
        public int read(char[] b)
        public int read(char[] b, int offset, int len)




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   34
Methods of Reader Class



        public int read()
        public int read(char[] b)
        public int read(char[] b, int offset, int len)
        public long skip(long count)




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   35
Methods of Reader Class



        public int read()
        public int read(char[] b)
        public int read(char[] b, int offset, int len)
        public long skip(long count)
        public boolean ready()




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   36
Methods of Reader Class



        public int read()
        public int read(char[] b)
        public int read(char[] b, int offset, int len)
        public long skip(long count)
        public boolean ready()
        public void mark(int readlimit)




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   37
Methods of Reader Class



        public int read()
        public int read(char[] b)
        public int read(char[] b, int offset, int len)
        public long skip(long count)
        public boolean ready()
        public void mark(int readlimit)
        public void reset()




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   38
Methods of Reader Class



        public int read()
        public int read(char[] b)
        public int read(char[] b, int offset, int len)
        public long skip(long count)
        public boolean ready()
        public void mark(int readlimit)
        public void reset()
        public boolean markSupported()




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   39
Methods of Reader Class



        public int read()
        public int read(char[] b)
        public int read(char[] b, int offset, int len)
        public long skip(long count)
        public boolean ready()
        public void mark(int readlimit)
        public void reset()
        public boolean markSupported()
        public void close()




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   40
InputStream Usage




    Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   41
OutputStream Usage




    Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   42
Bridge Classes



        OutputStreamWriter and InputStreamReader
        Character Base Stream Classes which inturns work on bytes.
        Handles unicode character and bytes both.
        Encoding and Decoding of unicode character from and to
        various character set.
        java.nio.charset package has classes which handle
        encoding and decoding.
        class Charset represents different character set.




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   43
OutputStreamWriter




    Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   44
InputStream Reader




    Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   45
FileInput and FileOutput Stream




        Output and input of binary files.




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   46
FileInput and FileOutput Stream




        Output and input of binary files.
        FileOutputStream create and write bytes in to physical file.




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   47
FileInput and FileOutput Stream




        Output and input of binary files.
        FileOutputStream create and write bytes in to physical file.
        If file exists it overwrites it until append flag is used.




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   48
FileInput and FileOutput Stream




        Output and input of binary files.
        FileOutputStream create and write bytes in to physical file.
        If file exists it overwrites it until append flag is used.
        Inherits all the methods from the OutputStream.




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   49
FileInput and FileOutput Stream




        Output and input of binary files.
        FileOutputStream create and write bytes in to physical file.
        If file exists it overwrites it until append flag is used.
        Inherits all the methods from the OutputStream.
        Additional methods are
        public FileDescriptor getFD()
        public FileChannel getChannel()




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   50
FileDescriptor




        Whenever any file is opened for input or output, it uses a file
        descriptor.




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   51
FileDescriptor




        Whenever any file is opened for input or output, it uses a file
        descriptor.
        0=Standard Input




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   52
FileDescriptor




        Whenever any file is opened for input or output, it uses a file
        descriptor.
        0=Standard Input
        1=Standard Output




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   53
FileDescriptor




        Whenever any file is opened for input or output, it uses a file
        descriptor.
        0=Standard Input
        1=Standard Output
        2=Standard Error




     Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551   54

More Related Content

What's hot

11.the novel lossless text compression technique using ambigram logic and huf...
11.the novel lossless text compression technique using ambigram logic and huf...11.the novel lossless text compression technique using ambigram logic and huf...
11.the novel lossless text compression technique using ambigram logic and huf...
Alexander Decker
 
Acm aleppo cpc training eighth session
Acm aleppo cpc training eighth sessionAcm aleppo cpc training eighth session
Acm aleppo cpc training eighth session
Ahmad Bashar Eter
 
Acm aleppo cpc training ninth session
Acm aleppo cpc training ninth sessionAcm aleppo cpc training ninth session
Acm aleppo cpc training ninth session
Ahmad Bashar Eter
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
SaranyaK68
 
Huffman analysis
Huffman analysisHuffman analysis
Huffman analysis
Abubakar Sultan
 
Chapter Three(2)
Chapter Three(2)Chapter Three(2)
Chapter Three(2)
bolovv
 
Aspects of software naturalness through the generation of IdentifierNames
Aspects of software naturalness through the generation of IdentifierNamesAspects of software naturalness through the generation of IdentifierNames
Aspects of software naturalness through the generation of IdentifierNames
Oleksandr Zaitsev
 
Introduction To Programming with Python
Introduction To Programming with PythonIntroduction To Programming with Python
Introduction To Programming with Python
Sushant Mane
 
Lec32
Lec32Lec32
Huffman codes
Huffman codesHuffman codes
Huffman codes
Nargis Ehsan
 
Acm aleppo cpc training second session
Acm aleppo cpc training second sessionAcm aleppo cpc training second session
Acm aleppo cpc training second session
Ahmad Bashar Eter
 
Acm aleppo cpc training introduction 1
Acm aleppo cpc training introduction 1Acm aleppo cpc training introduction 1
Acm aleppo cpc training introduction 1
Ahmad Bashar Eter
 
Designing a Software Application for Fiber Fano Planes
Designing a Software Application for Fiber Fano PlanesDesigning a Software Application for Fiber Fano Planes
Designing a Software Application for Fiber Fano Planes
inventionjournals
 
Functional Programming in Pattern-Match-Oriented Programming Style <Programmi...
Functional Programming in Pattern-Match-Oriented Programming Style <Programmi...Functional Programming in Pattern-Match-Oriented Programming Style <Programmi...
Functional Programming in Pattern-Match-Oriented Programming Style <Programmi...
Rakuten Group, Inc.
 
Huffman coding || Huffman Tree
Huffman coding || Huffman TreeHuffman coding || Huffman Tree
Huffman coding || Huffman Tree
SatishKumarInumarthi
 
The Egison Programming Language
The Egison Programming LanguageThe Egison Programming Language
The Egison Programming Language
Rakuten Group, Inc.
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
Muhammad Saqib Rehan
 
Regex posix
Regex posixRegex posix
Regex posix
sana mateen
 
11 Unit 1 Chapter 03 Data Handling
11   Unit 1 Chapter 03 Data Handling11   Unit 1 Chapter 03 Data Handling
11 Unit 1 Chapter 03 Data Handling
Praveen M Jigajinni
 

What's hot (19)

11.the novel lossless text compression technique using ambigram logic and huf...
11.the novel lossless text compression technique using ambigram logic and huf...11.the novel lossless text compression technique using ambigram logic and huf...
11.the novel lossless text compression technique using ambigram logic and huf...
 
Acm aleppo cpc training eighth session
Acm aleppo cpc training eighth sessionAcm aleppo cpc training eighth session
Acm aleppo cpc training eighth session
 
Acm aleppo cpc training ninth session
Acm aleppo cpc training ninth sessionAcm aleppo cpc training ninth session
Acm aleppo cpc training ninth session
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Huffman analysis
Huffman analysisHuffman analysis
Huffman analysis
 
Chapter Three(2)
Chapter Three(2)Chapter Three(2)
Chapter Three(2)
 
Aspects of software naturalness through the generation of IdentifierNames
Aspects of software naturalness through the generation of IdentifierNamesAspects of software naturalness through the generation of IdentifierNames
Aspects of software naturalness through the generation of IdentifierNames
 
Introduction To Programming with Python
Introduction To Programming with PythonIntroduction To Programming with Python
Introduction To Programming with Python
 
Lec32
Lec32Lec32
Lec32
 
Huffman codes
Huffman codesHuffman codes
Huffman codes
 
Acm aleppo cpc training second session
Acm aleppo cpc training second sessionAcm aleppo cpc training second session
Acm aleppo cpc training second session
 
Acm aleppo cpc training introduction 1
Acm aleppo cpc training introduction 1Acm aleppo cpc training introduction 1
Acm aleppo cpc training introduction 1
 
Designing a Software Application for Fiber Fano Planes
Designing a Software Application for Fiber Fano PlanesDesigning a Software Application for Fiber Fano Planes
Designing a Software Application for Fiber Fano Planes
 
Functional Programming in Pattern-Match-Oriented Programming Style <Programmi...
Functional Programming in Pattern-Match-Oriented Programming Style <Programmi...Functional Programming in Pattern-Match-Oriented Programming Style <Programmi...
Functional Programming in Pattern-Match-Oriented Programming Style <Programmi...
 
Huffman coding || Huffman Tree
Huffman coding || Huffman TreeHuffman coding || Huffman Tree
Huffman coding || Huffman Tree
 
The Egison Programming Language
The Egison Programming LanguageThe Egison Programming Language
The Egison Programming Language
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
 
Regex posix
Regex posixRegex posix
Regex posix
 
11 Unit 1 Chapter 03 Data Handling
11   Unit 1 Chapter 03 Data Handling11   Unit 1 Chapter 03 Data Handling
11 Unit 1 Chapter 03 Data Handling
 

Viewers also liked

Java script
Java scriptJava script
Java script
AshishSingh Bhatia
 
JavaScript State of the Union - Jan 2013
JavaScript State of the Union - Jan 2013JavaScript State of the Union - Jan 2013
JavaScript State of the Union - Jan 2013
Kentucky JavaScript Users Group
 
IPv6
IPv6IPv6
Syllabus of BCA Second Year JAMMU University
Syllabus of BCA Second Year JAMMU UniversitySyllabus of BCA Second Year JAMMU University
Syllabus of BCA Second Year JAMMU University
Ravi Shairaywal
 
HTTP Basic and Servlet Basic
HTTP Basic and Servlet BasicHTTP Basic and Servlet Basic
HTTP Basic and Servlet Basic
ashishspace
 
Servlet Event framework
Servlet Event frameworkServlet Event framework
Servlet Event framework
AshishSingh Bhatia
 
Nested and Enum in Java
Nested and Enum in JavaNested and Enum in Java
Nested and Enum in Java
ashishspace
 
I/O In Java Part 2
I/O In Java Part 2I/O In Java Part 2
I/O In Java Part 2
ashishspace
 

Viewers also liked (8)

Java script
Java scriptJava script
Java script
 
JavaScript State of the Union - Jan 2013
JavaScript State of the Union - Jan 2013JavaScript State of the Union - Jan 2013
JavaScript State of the Union - Jan 2013
 
IPv6
IPv6IPv6
IPv6
 
Syllabus of BCA Second Year JAMMU University
Syllabus of BCA Second Year JAMMU UniversitySyllabus of BCA Second Year JAMMU University
Syllabus of BCA Second Year JAMMU University
 
HTTP Basic and Servlet Basic
HTTP Basic and Servlet BasicHTTP Basic and Servlet Basic
HTTP Basic and Servlet Basic
 
Servlet Event framework
Servlet Event frameworkServlet Event framework
Servlet Event framework
 
Nested and Enum in Java
Nested and Enum in JavaNested and Enum in Java
Nested and Enum in Java
 
I/O In Java Part 2
I/O In Java Part 2I/O In Java Part 2
I/O In Java Part 2
 

Similar to Java I/O Part 2

Java Input and Output
Java Input and OutputJava Input and Output
Java Input and Output
Ducat India
 
UNIT4-IO,Generics,String Handling.pdf Notes
UNIT4-IO,Generics,String Handling.pdf NotesUNIT4-IO,Generics,String Handling.pdf Notes
UNIT4-IO,Generics,String Handling.pdf Notes
SakkaravarthiS1
 
شرح مقرر البرمجة 2 لغة جافا - الوحدة الثامنة
شرح مقرر البرمجة 2   لغة جافا - الوحدة الثامنةشرح مقرر البرمجة 2   لغة جافا - الوحدة الثامنة
شرح مقرر البرمجة 2 لغة جافا - الوحدة الثامنة
جامعة القدس المفتوحة
 
Os Vanrossum
Os VanrossumOs Vanrossum
Os Vanrossum
oscon2007
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)
Saifur Rahman
 
Java Tutorial Lab 6
Java Tutorial Lab 6Java Tutorial Lab 6
Java Tutorial Lab 6
Berk Soysal
 
Java Day-6
Java Day-6Java Day-6
Java Day-6
People Strategists
 
Ecs40 winter 2017 homework 3
Ecs40 winter 2017 homework 3Ecs40 winter 2017 homework 3
Ecs40 winter 2017 homework 3
JenniferBall44
 
Fantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOFFantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOF
Dror Bereznitsky
 
Unit IV Notes.docx
Unit IV Notes.docxUnit IV Notes.docx
Unit IV Notes.docx
GayathriRHICETCSESTA
 
Syntax Comparison of Golang with C and Java - Mindbowser
Syntax Comparison of Golang with C and Java - MindbowserSyntax Comparison of Golang with C and Java - Mindbowser
Syntax Comparison of Golang with C and Java - Mindbowser
Mindbowser Inc
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
arivukarasi2
 
LiangChapter4 Unicode , ASCII Code .ppt
LiangChapter4 Unicode , ASCII Code  .pptLiangChapter4 Unicode , ASCII Code  .ppt
LiangChapter4 Unicode , ASCII Code .ppt
zainiiqbal761
 
Inputstream
InputstreamInputstream
Inputstream
Rajasekhar Reddy
 
Inputstream
InputstreamInputstream
Inputstream
Rajasekhar Reddy
 
String Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesString Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and Interfaces
Prabu U
 
2016 bioinformatics i_python_part_2_strings_wim_vancriekinge
2016 bioinformatics i_python_part_2_strings_wim_vancriekinge2016 bioinformatics i_python_part_2_strings_wim_vancriekinge
2016 bioinformatics i_python_part_2_strings_wim_vancriekinge
Prof. Wim Van Criekinge
 
H U F F M A N Algorithm Class
H U F F M A N Algorithm ClassH U F F M A N Algorithm Class
H U F F M A N Algorithm Class
Jade Danial
 
MODULE. .pptx
MODULE.                              .pptxMODULE.                              .pptx
MODULE. .pptx
Alpha337901
 
Compiler worksheet
Compiler worksheetCompiler worksheet
Compiler worksheet
ArthyR3
 

Similar to Java I/O Part 2 (20)

Java Input and Output
Java Input and OutputJava Input and Output
Java Input and Output
 
UNIT4-IO,Generics,String Handling.pdf Notes
UNIT4-IO,Generics,String Handling.pdf NotesUNIT4-IO,Generics,String Handling.pdf Notes
UNIT4-IO,Generics,String Handling.pdf Notes
 
شرح مقرر البرمجة 2 لغة جافا - الوحدة الثامنة
شرح مقرر البرمجة 2   لغة جافا - الوحدة الثامنةشرح مقرر البرمجة 2   لغة جافا - الوحدة الثامنة
شرح مقرر البرمجة 2 لغة جافا - الوحدة الثامنة
 
Os Vanrossum
Os VanrossumOs Vanrossum
Os Vanrossum
 
C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)C cheat sheet for varsity (extreme edition)
C cheat sheet for varsity (extreme edition)
 
Java Tutorial Lab 6
Java Tutorial Lab 6Java Tutorial Lab 6
Java Tutorial Lab 6
 
Java Day-6
Java Day-6Java Day-6
Java Day-6
 
Ecs40 winter 2017 homework 3
Ecs40 winter 2017 homework 3Ecs40 winter 2017 homework 3
Ecs40 winter 2017 homework 3
 
Fantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOFFantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOF
 
Unit IV Notes.docx
Unit IV Notes.docxUnit IV Notes.docx
Unit IV Notes.docx
 
Syntax Comparison of Golang with C and Java - Mindbowser
Syntax Comparison of Golang with C and Java - MindbowserSyntax Comparison of Golang with C and Java - Mindbowser
Syntax Comparison of Golang with C and Java - Mindbowser
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
 
LiangChapter4 Unicode , ASCII Code .ppt
LiangChapter4 Unicode , ASCII Code  .pptLiangChapter4 Unicode , ASCII Code  .ppt
LiangChapter4 Unicode , ASCII Code .ppt
 
Inputstream
InputstreamInputstream
Inputstream
 
Inputstream
InputstreamInputstream
Inputstream
 
String Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesString Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and Interfaces
 
2016 bioinformatics i_python_part_2_strings_wim_vancriekinge
2016 bioinformatics i_python_part_2_strings_wim_vancriekinge2016 bioinformatics i_python_part_2_strings_wim_vancriekinge
2016 bioinformatics i_python_part_2_strings_wim_vancriekinge
 
H U F F M A N Algorithm Class
H U F F M A N Algorithm ClassH U F F M A N Algorithm Class
H U F F M A N Algorithm Class
 
MODULE. .pptx
MODULE.                              .pptxMODULE.                              .pptx
MODULE. .pptx
 
Compiler worksheet
Compiler worksheetCompiler worksheet
Compiler worksheet
 

More from AshishSingh Bhatia

Servlet Filter
Servlet FilterServlet Filter
Servlet Filter
AshishSingh Bhatia
 
JSP : Creating Custom Tag
JSP : Creating Custom Tag JSP : Creating Custom Tag
JSP : Creating Custom Tag
AshishSingh Bhatia
 
Dom Basics
Dom BasicsDom Basics
Dom Basics
AshishSingh Bhatia
 
Java I/O Part 1
Java I/O Part 1Java I/O Part 1
Java I/O Part 1
AshishSingh Bhatia
 
Nested and Enum Type in Java
Nested and Enum Type in JavaNested and Enum Type in Java
Nested and Enum Type in Java
AshishSingh Bhatia
 
Http and Servlet basics
Http and Servlet basicsHttp and Servlet basics
Http and Servlet basics
AshishSingh Bhatia
 

More from AshishSingh Bhatia (6)

Servlet Filter
Servlet FilterServlet Filter
Servlet Filter
 
JSP : Creating Custom Tag
JSP : Creating Custom Tag JSP : Creating Custom Tag
JSP : Creating Custom Tag
 
Dom Basics
Dom BasicsDom Basics
Dom Basics
 
Java I/O Part 1
Java I/O Part 1Java I/O Part 1
Java I/O Part 1
 
Nested and Enum Type in Java
Nested and Enum Type in JavaNested and Enum Type in Java
Nested and Enum Type in Java
 
Http and Servlet basics
Http and Servlet basicsHttp and Servlet basics
Http and Servlet basics
 

Recently uploaded

BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
Constructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective CommunicationConstructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective Communication
Chevonnese Chevers Whyte, MBA, B.Sc.
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 

Recently uploaded (20)

BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
Constructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective CommunicationConstructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective Communication
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 

Java I/O Part 2

  • 1. File IO in Java Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 September 21, 2012 Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 1
  • 2. AGENDA Overview of IO Classes OutputStream of IO InputStream of IO Writer of IO Reader of IO Methods of OutputStream Class Methods of Writer Class Methods of Writer Class Extra Methods of InputStream Class Methods of Reader Class InputStream Usage OutputStream Usage Bridge Classes OutputStreamWriter InputStream Reader FileInput and FileOutput Stream Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 2
  • 3. Overview of IO Classes Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 3
  • 4. OutputStream of IO Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 4
  • 5. InputStream of IO Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 5
  • 6. Writer of IO Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 6
  • 7. Reader of IO Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 7
  • 8. Methods of OutputStream Class public void write(int b) Writes a single byte to an output stream. Why we need int as argument? Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 8
  • 9. Methods of OutputStream Class public void write(int b) Writes a single byte to an output stream. Why we need int as argument? public void write(byte[] b) Writes complete byte array in to an outputstream. Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 9
  • 10. Methods of OutputStream Class public void write(int b) Writes a single byte to an output stream. Why we need int as argument? public void write(byte[] b) Writes complete byte array in to an outputstream. public void write(byte[] b, int offset, int len) Write a subrange from offset to specified length[number of bytes]. Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 10
  • 11. Methods of OutputStream Class public void write(int b) Writes a single byte to an output stream. Why we need int as argument? public void write(byte[] b) Writes complete byte array in to an outputstream. public void write(byte[] b, int offset, int len) Write a subrange from offset to specified length[number of bytes]. public void flush() Flushes the output buffer. Ensures the contents are written to the destination. Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 11
  • 12. Methods of OutputStream Class public void write(int b) Writes a single byte to an output stream. Why we need int as argument? public void write(byte[] b) Writes complete byte array in to an outputstream. public void write(byte[] b, int offset, int len) Write a subrange from offset to specified length[number of bytes]. public void flush() Flushes the output buffer. Ensures the contents are written to the destination. public void close() Closes the outputstream. Further write will generate IOException Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 12
  • 13. Methods of Writer Class public void write(int ch) Writes a single character to an output stream. Why we need int as argument? Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 13
  • 14. Methods of Writer Class public void write(int ch) Writes a single character to an output stream. Why we need int as argument? public void write(char[] ch) Writes complete character array in to an outputstream. Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 14
  • 15. Methods of Writer Class public void write(int ch) Writes a single character to an output stream. Why we need int as argument? public void write(char[] ch) Writes complete character array in to an outputstream. public void write(char[] b, int offset, int len) Write a subrange from offset to specified length[number of character]. Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 15
  • 16. Methods of Writer Class public void write(int ch) Writes a single character to an output stream. Why we need int as argument? public void write(char[] ch) Writes complete character array in to an outputstream. public void write(char[] b, int offset, int len) Write a subrange from offset to specified length[number of character]. public void flush() Flushes the output buffer. Ensures the contents are written to the destination. Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 16
  • 17. Methods of Writer Class public void write(int ch) Writes a single character to an output stream. Why we need int as argument? public void write(char[] ch) Writes complete character array in to an outputstream. public void write(char[] b, int offset, int len) Write a subrange from offset to specified length[number of character]. public void flush() Flushes the output buffer. Ensures the contents are written to the destination. public void close() Closes the writer. Further write will generate IOException Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 17
  • 18. Methods of Writer Class Extra String is a sequence of Character. public void write(String s) Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 18
  • 19. Methods of Writer Class Extra String is a sequence of Character. public void write(String s) public void write(String s, int offset, int len) Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 19
  • 20. Methods of Writer Class Extra String is a sequence of Character. public void write(String s) public void write(String s, int offset, int len) public void append(char ch) Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 20
  • 21. Methods of Writer Class Extra String is a sequence of Character. public void write(String s) public void write(String s, int offset, int len) public void append(char ch) public void append(CharSequence cs) Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 21
  • 22. Methods of Writer Class Extra String is a sequence of Character. public void write(String s) public void write(String s, int offset, int len) public void append(char ch) public void append(CharSequence cs) public void append(CharSequence cs, int offset, int len) Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 22
  • 23. Methods of InputStream Class public int read() Read the integer representation of the next available byte of input. Returns -1 when the end of file is encountered. Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 23
  • 24. Methods of InputStream Class public int read() Read the integer representation of the next available byte of input. Returns -1 when the end of file is encountered. public int read(byte[] b) Attempt to read up to b.length bytes in the the b array. Returns the number of actual bytes read. -1 is returned when the end of file is encountered. Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 24
  • 25. Methods of InputStream Class public int read() Read the integer representation of the next available byte of input. Returns -1 when the end of file is encountered. public int read(byte[] b) Attempt to read up to b.length bytes in the the b array. Returns the number of actual bytes read. -1 is returned when the end of file is encountered. public int read(byte[] b, int offset, int len) Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 25
  • 26. Methods of InputStream Class public int read() Read the integer representation of the next available byte of input. Returns -1 when the end of file is encountered. public int read(byte[] b) Attempt to read up to b.length bytes in the the b array. Returns the number of actual bytes read. -1 is returned when the end of file is encountered. public int read(byte[] b, int offset, int len) public long skip(long count) count indicates number of bytes to be skipped and return the number of byte skipped or -1 in case of end of file. Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 26
  • 27. Methods of InputStream Class public int read() Read the integer representation of the next available byte of input. Returns -1 when the end of file is encountered. public int read(byte[] b) Attempt to read up to b.length bytes in the the b array. Returns the number of actual bytes read. -1 is returned when the end of file is encountered. public int read(byte[] b, int offset, int len) public long skip(long count) count indicates number of bytes to be skipped and return the number of byte skipped or -1 in case of end of file. public int available() Number of bytes available for reading. Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 27
  • 28. Methods of InputStream Class public int read() Read the integer representation of the next available byte of input. Returns -1 when the end of file is encountered. public int read(byte[] b) Attempt to read up to b.length bytes in the the b array. Returns the number of actual bytes read. -1 is returned when the end of file is encountered. public int read(byte[] b, int offset, int len) public long skip(long count) count indicates number of bytes to be skipped and return the number of byte skipped or -1 in case of end of file. public int available() Number of bytes available for reading. public void mark(int readlimit) Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 28
  • 29. Methods of InputStream Class public int read() Read the integer representation of the next available byte of input. Returns -1 when the end of file is encountered. public int read(byte[] b) Attempt to read up to b.length bytes in the the b array. Returns the number of actual bytes read. -1 is returned when the end of file is encountered. public int read(byte[] b, int offset, int len) public long skip(long count) count indicates number of bytes to be skipped and return the number of byte skipped or -1 in case of end of file. public int available() Number of bytes available for reading. public void mark(int readlimit) public void reset() Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 29
  • 30. Methods of InputStream Class public int read() Read the integer representation of the next available byte of input. Returns -1 when the end of file is encountered. public int read(byte[] b) Attempt to read up to b.length bytes in the the b array. Returns the number of actual bytes read. -1 is returned when the end of file is encountered. public int read(byte[] b, int offset, int len) public long skip(long count) count indicates number of bytes to be skipped and return the number of byte skipped or -1 in case of end of file. public int available() Number of bytes available for reading. public void mark(int readlimit) public void reset() public boolean markSupported() Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 30
  • 31. Methods of InputStream Class public int read() Read the integer representation of the next available byte of input. Returns -1 when the end of file is encountered. public int read(byte[] b) Attempt to read up to b.length bytes in the the b array. Returns the number of actual bytes read. -1 is returned when the end of file is encountered. public int read(byte[] b, int offset, int len) public long skip(long count) count indicates number of bytes to be skipped and return the number of byte skipped or -1 in case of end of file. public int available() Number of bytes available for reading. public void mark(int readlimit) public void reset() public boolean markSupported() public void close() Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 31
  • 32. Methods of Reader Class public int read() Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 32
  • 33. Methods of Reader Class public int read() public int read(char[] b) Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 33
  • 34. Methods of Reader Class public int read() public int read(char[] b) public int read(char[] b, int offset, int len) Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 34
  • 35. Methods of Reader Class public int read() public int read(char[] b) public int read(char[] b, int offset, int len) public long skip(long count) Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 35
  • 36. Methods of Reader Class public int read() public int read(char[] b) public int read(char[] b, int offset, int len) public long skip(long count) public boolean ready() Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 36
  • 37. Methods of Reader Class public int read() public int read(char[] b) public int read(char[] b, int offset, int len) public long skip(long count) public boolean ready() public void mark(int readlimit) Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 37
  • 38. Methods of Reader Class public int read() public int read(char[] b) public int read(char[] b, int offset, int len) public long skip(long count) public boolean ready() public void mark(int readlimit) public void reset() Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 38
  • 39. Methods of Reader Class public int read() public int read(char[] b) public int read(char[] b, int offset, int len) public long skip(long count) public boolean ready() public void mark(int readlimit) public void reset() public boolean markSupported() Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 39
  • 40. Methods of Reader Class public int read() public int read(char[] b) public int read(char[] b, int offset, int len) public long skip(long count) public boolean ready() public void mark(int readlimit) public void reset() public boolean markSupported() public void close() Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 40
  • 41. InputStream Usage Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 41
  • 42. OutputStream Usage Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 42
  • 43. Bridge Classes OutputStreamWriter and InputStreamReader Character Base Stream Classes which inturns work on bytes. Handles unicode character and bytes both. Encoding and Decoding of unicode character from and to various character set. java.nio.charset package has classes which handle encoding and decoding. class Charset represents different character set. Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 43
  • 44. OutputStreamWriter Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 44
  • 45. InputStream Reader Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 45
  • 46. FileInput and FileOutput Stream Output and input of binary files. Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 46
  • 47. FileInput and FileOutput Stream Output and input of binary files. FileOutputStream create and write bytes in to physical file. Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 47
  • 48. FileInput and FileOutput Stream Output and input of binary files. FileOutputStream create and write bytes in to physical file. If file exists it overwrites it until append flag is used. Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 48
  • 49. FileInput and FileOutput Stream Output and input of binary files. FileOutputStream create and write bytes in to physical file. If file exists it overwrites it until append flag is used. Inherits all the methods from the OutputStream. Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 49
  • 50. FileInput and FileOutput Stream Output and input of binary files. FileOutputStream create and write bytes in to physical file. If file exists it overwrites it until append flag is used. Inherits all the methods from the OutputStream. Additional methods are public FileDescriptor getFD() public FileChannel getChannel() Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 50
  • 51. FileDescriptor Whenever any file is opened for input or output, it uses a file descriptor. Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 51
  • 52. FileDescriptor Whenever any file is opened for input or output, it uses a file descriptor. 0=Standard Input Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 52
  • 53. FileDescriptor Whenever any file is opened for input or output, it uses a file descriptor. 0=Standard Input 1=Standard Output Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 53
  • 54. FileDescriptor Whenever any file is opened for input or output, it uses a file descriptor. 0=Standard Input 1=Standard Output 2=Standard Error Prof. AshishSingh Bhatia, ast.bhatia@gmail.com, ashish@asbspace.in, Web: asbspace.in, M:9879009551 54