Slides IO Stream.ppt - Session I/O Streams Core Java...

This preview shows page 1 - 15 out of 43 pages.

Core Java / Session 31 / 1 of 10 Session I/O Streams
Core Java / Session 31 / 2 of 10 Objectives Define streams Describe the InputStream and OutputStream classes Describe the I/O Byte array
Core Java / Session 31 / 3 of 10 Objectives Describe the File I/O Classes Filtered Input and Output Classes Buffered I/O Classes Reader and Writer Classes Character Array and String Input and Output Classes PrinterWriter Class
Core Java / Session 31 / 4 of 10 Objectives Describe DataInput Interface Describe DataOutput Interface Describe RandomAccessFile Class Explain java.awt.print Package
Core Java / Session 31 / 5 of 10 - io-stream.php
Core Java / Session 31 / 6 of 10 Streams Streams are pipelines for sending and receiving information in Java programs When a stream is read or written, the other threads are blocked If an error occurs while reading or writing a stream, an IOException is thrown Class ‘java.lang.System’ defines the standard input and output streams
Core Java / Session 31 / 7 of 10 I/O Stream classes System.out class System.in class System.err class
Core Java / Session 31 / 8 of 10 InputStream Class Is an abstract class Defines how data is received Provides a number of methods for reading, and taking streams of data as input Methods: read( ) available( ) close ( ) mark ( ) markSupported( ) reset( ) skip( )
Core Java / Session 31 / 9 of 10 OutputStream Class Is abstract Defines how outputs are written to streams Provides a set of methods that help in creating, writing and processing output streams Methods write(int) write(byte[ ]) write(byte[ ], int, int) flush( ) close( )
Core Java / Session 31 / 10 of 10 Byte Array Input Use memory buffers ByteArrayInputStream Class Creates an input stream from the memory buffer which is an array of bytes Does not support any new methods Overrides methods of the class InputStream, such as ‘read()’, ‘skip()’, ‘available()’ and ‘reset()’
Core Java / Session 31 / 11 of 10 Byte Array Output Use memory buffers ByteArrayOutputStream Class Creates an output stream on a byte array Provides additional capabilities for the output array to grow, to accommodate the new data that is written Also provides methods to convert the stream to a byte array, or a String object
Core Java / Session 31 / 12 of 10 Byte Array Output (Contd…) Methods of ByteArrayOutputStream Class: reset( ) size( ) writeTo( )
Core Java / Session 31 / 13 of 10 File I/O classes Classes that help Java to support file input and output operations: File FileDescriptor FileInputStream FileOutputStream File, FileDescriptor, and RandomAccessFile classes are used to support direct or random access input and output
Core Java / Session 31 / 14 of 10 File Class Is used to access file and directory objects The files are named according to the file- naming conventions of the host operating system This class provides

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture