The document discusses input/output files in Java. It covers the key classes used for reading and writing files in Java, including FileInputStream, FileOutputStream, FileReader, and FileWriter. It also discusses byte streams versus character streams, and provides examples of reading and writing to files in Java using these classes. Standard input/output streams like System.in and System.out are also covered.
Understanding Habits
A habit is a behavior repeated so frequently that it becomes automatic. The brain, ever efficient, loves to automate frequently repeated actions to conserve energy. This mechanism is why you can drive home without consciously thinking about every turn or brush your teeth while thinking about something entirely different.
The formation of a habit follows a loop: cue → craving → response → reward. This neurological cycle governs everything from snacking at 3 PM to checking our phones the moment we wake up. Understanding this cycle allows us to consciously engineer habits that serve us—or break those that don’t.
But here’s the kicker: the strength of a habit lies not in its size but in its repetition. A single push-up doesn’t get you fit, and one salad won’t transform your health. But repeated over weeks and months, these actions wield enormous influence.
The Role of Identity
One of the most profound insights in behavior change is the link between identity and habits. We tend to act in alignment with who we believe we are. This means that lasting change often requires a shift in self-perception.
Consider two people trying to quit smoking. One says, “No thanks, I’m trying to quit,” while the other says, “No thanks, I’m not a smoker.” The second person has internalized a new identity. They are no longer someone resisting temptation—they are someone for whom smoking is simply not part of who they are.
This concept works positively too. Want to become a writer? Start identifying as one. Not based on a published book, but on the simple, repeated act of writing. Identity builds through action, and the most effective way to change who we are is to change what we do—repeatedly.
Understanding Habits
A habit is a behavior repeated so frequently that it becomes automatic. The brain, ever efficient, loves to automate frequently repeated actions to conserve energy. This mechanism is why you can drive home without consciously thinking about every turn or brush your teeth while thinking about something entirely different.
The formation of a habit follows a loop: cue → craving → response → reward. This neurological cycle governs everything from snacking at 3 PM to checking our phones the moment we wake up. Understanding this cycle allows us to consciously engineer habits that serve us—or break those that don’t.
But here’s the kicker: the strength of a habit lies not in its size but in its repetition. A single push-up doesn’t get you fit, and one salad won’t transform your health. But repeated over weeks and months, these actions wield enormous influence.
The Role of Identity
One of the most profound insights in behavior change is the link between identity and habits. We tend to act in alignment with who we believe we are. This means that lasting change often requires a shift in self-perception.
Consider two people trying to quit smoking. One says, “No thanks, I’m trying to quit,” while the other says, “No thanks, I’m not a smoker.” Th
The document discusses input and output streams in Java. It provides an overview of character streams, byte streams, and connected streams. It explains how to read from and write to files using FileInputStream, FileOutputStream, FileReader, and FileWriter. It emphasizes the importance of specifying the correct character encoding when working with text files. An example demonstrates reading an image file as bytes, modifying some bytes, and writing the image to a new file.
The document discusses Java input/output (I/O) streams. It covers byte streams like FileInputStream and FileOutputStream for reading and writing bytes. It also covers character streams like FileReader and FileWriter for reading and writing characters. Filtered streams like BufferedInputStream are discussed which add functionality to underlying streams. The document also covers random access files and the File class.
This document provides an overview of streams and file input/output (I/O) in Java. It discusses different types of streams like input streams, output streams, byte streams, text streams, and standard streams. It also covers FileInputStream, FileOutputStream, FileReader, FileWriter, and how to use streams to read from and write to files and directories. Examples are provided demonstrating how to copy files, read from the keyboard, and use byte arrays as input streams.
This chapter discusses various methods of file input and output in Java, including low-level file I/O using FileInputStream and FileOutputStream, high-level file I/O using DataInputStream and DataOutputStream to read and write primitive data types, reading and writing text files using PrintWriter, BufferedReader, and Scanner, and object file I/O using ObjectInputStream and ObjectOutputStream to save and load objects. It also covers using JFileChooser to allow users to select files and applying file filters.
This chapter discusses various methods of file input and output in Java, including low-level file I/O using FileInputStream and FileOutputStream, high-level file I/O using DataInputStream and DataOutputStream to read and write primitive data types, reading and writing text files using PrintWriter, BufferedReader, and Scanner, and object file I/O using ObjectInputStream and ObjectOutputStream to save and load objects. It also covers using JFileChooser to allow users to select files and applying file filters.
This document provides an overview of Java input-output (I/O) streams and classes. It discusses the core stream classes like InputStream, OutputStream, Reader, Writer and their subclasses like FileInputStream, FileOutputStream, FileReader, FileWriter. It also covers buffered stream classes like BufferedInputStream, BufferedOutputStream, BufferedReader, BufferedWriter which provide better performance. Examples are given to demonstrate reading, writing and file handling using these stream classes.
This document provides an overview of input/output operations in Java using the java.io package. It discusses streams and channels, file I/O, reading and writing files, serialization, and the Observer and Observable interfaces. The key classes covered include File, PrintWriter, Scanner, InputStream, OutputStream, Reader, Writer, Buffer, Channel, and classes for serialization. Examples are provided for reading and writing files using byte streams, character streams, buffers, and channels.
This document discusses I/O streams in Java. It defines streams as sequences of bytes that flow from a source to a destination. Streams can be categorized as character streams for text data or byte streams for raw binary data. Streams are also categorized as data streams that act as sources or destinations, or processing streams that alter or manage stream information. The Java IO package contains classes for defining input and output streams of different types.
The document discusses various Java I/O stream classes:
- FileInputStream and FileOutputStream are used for reading and writing raw bytes to files.
- InputStreamReader and OutputStreamWriter bridge byte streams to character streams using a specified character encoding.
- FileReader and FileWriter are built on top of InputStreamReader and OutputStreamWriter respectively, and are used for reading and writing character streams from files.
This document provides information on input/output operations, file handling, and serialization in Java. It discusses Java's input and output streams for reading and writing bytes and characters. It describes classes for working with files like File, FileInputStream, FileOutputStream, FileReader, and FileWriter. Examples are given for reading from and writing to files and the console. The document also introduces serialization in Java for converting objects to byte streams for storage or transmission.
This document discusses files and streams in Java. It covers key concepts like:
- Streams represent sources of input or destinations of output and support different data types.
- Input streams read data from sources one item at a time, while output streams write to destinations.
- Byte streams handle raw bytes, while character streams automatically translate character encodings.
- Common stream classes include FileInputStream, FileOutputStream, FileReader and FileWriter for file I/O.
- The predefined System streams like System.in and System.out represent standard input/output.
The document discusses streams and input/output in Java. It introduces streams as a way to represent ordered sequences of data in a uniform manner across different I/O devices. It describes the different types of streams in Java, including byte streams and character streams. It also outlines some of the key input and output stream classes in Java and common stream operations like reading, writing, skipping bytes, and closing streams.
This document discusses Java's input/output (I/O) capabilities through the java.io package. It describes the core I/O stream classes like InputStream, OutputStream, Reader and Writer. It also covers file I/O using File and FileInput/OutputStream classes. Buffered, filtered and character streams are explained. The use of serialization interfaces like Serializable and Externalizable for object I/O is summarized. The document provides examples of reading, writing and manipulating files and directories in Java.
This document provides an overview of Java I/O streams and how to open, use, and close them. It discusses how opening a stream creates a connection to external data, using a stream involves reading or writing data, and closing streams is important to release resources. It then gives examples of opening a FileReader stream, reading lines with a BufferedReader, and closing streams. The document also introduces LineReader and LineWriter classes that simplify reading and writing text files line-by-line in Java.
This document provides an overview of Java I/O streams and how to open, use, and close them. It discusses how opening a stream creates a connection to external data, using a stream involves reading or writing data, and closing streams is important to release resources. It then gives examples of opening a FileReader stream, reading lines with a BufferedReader, and includes code for a LineReader class to simplify reading text files and a LineWriter class to write text files.
The document discusses input/output streams in Java. It covers:
- Different types of data storage including transient RAM and persistent storage like disks.
- I/O sources and destinations like consoles, disks, networks etc. and how streams represent sequential bytes to abstract I/O details.
- Common Java I/O stream classes like FileReader, FileWriter, InputStream and OutputStream for reading/writing text and binary data from files.
- Using File class to represent files and directories with methods to check attributes, read content and manipulate files.
File input and output operations in Java are performed using streams. There are two types of streams - byte streams and character streams. Byte streams handle input/output at the byte level while character streams handle input/output at the character level using Unicode encoding. The File class in Java represents files and directories on the filesystem and provides methods to perform operations like creating, reading, updating and deleting files.
File Handling Presentation As well as File handling code in java Update, Delete, Search, View, Insert in file code are available in this presentation in you face some issues so contact me 03244064060 , Also in my Email: [email protected] and Twitter @azeemaj101
This document discusses Java I/O and streams. It begins by introducing files and the File class, which provides methods for obtaining file properties and manipulating files. It then discusses reading and writing files using byte streams like FileInputStream and FileOutputStream. Character streams like PrintWriter and BufferedReader are presented for console I/O. Other stream classes covered include buffered streams, object streams for serialization, and data streams for primitive types. The key methods of various stream classes are listed.
Java uses streams to handle input/output operations. Streams provide a standardized way to read from and write to various sources and sinks like files, networks, and buffers. There are byte streams that handle input/output of bytes and character streams that handle characters. Common stream classes include FileInputStream, FileOutputStream, BufferedReader, and BufferedWriter which are used to read from and write to files and console. Streams can be chained together for complex I/O processing.
This document discusses the modules, evaluation, textbook, and units for an Advanced Java course. The 5 units cover File Handling, Java Collection Framework and Event Handling, Swing and GUI Components, Networking & Database Connectivity. The internal evaluation includes 5 assignments worth 25 marks total and an MCQ test worth 25 marks. The textbook recommended is "Programming in Java2" by Dr.K.Somasundaram. Unit 1 covers File Input/Output streams, the File class, byte streams, character streams, and reading/writing files using FileInputStream, FileOutputStream, and RandomAccessFile.
This study will provide the audience with an understanding of the capabilities of soft tools such as Artificial Neural Networks (ANN), Support Vector Regression (SVR), Model Trees (MT), and Multi-Gene Genetic Programming (MGGP) as a statistical downscaling tool. Many projects are underway around the world to downscale the data from Global Climate Models (GCM). The majority of the statistical tools have a lengthy downscaling pipeline to follow. To improve its accuracy, the GCM data is re-gridded according to the grid points of the observed data, standardized, and, sometimes, bias-removal is required. The current work suggests that future precipitation can be predicted by using precipitation data from the nearest four grid points as input to soft tools and observed precipitation as output. This research aims to estimate precipitation trends in the near future (2021-2050), using 5 GCMs, for Pune, in the state of Maharashtra, India. The findings indicate that each one of the soft tools can model the precipitation with excellent accuracy as compared to the traditional method of Distribution Based Scaling (DBS). The results show that ANN models appear to give the best results, followed by MT, then MGGP, and finally SVR. This work is one of a kind in that it provides insights into the changing monsoon season in Pune. The anticipated average precipitation levels depict a rise of 300–500% in January, along with increases of 200-300% in February and March, and a 100-150% increase for April and December. In contrast, rainfall appears to be decreasing by 20-30% between June and September.
This chapter discusses various methods of file input and output in Java, including low-level file I/O using FileInputStream and FileOutputStream, high-level file I/O using DataInputStream and DataOutputStream to read and write primitive data types, reading and writing text files using PrintWriter, BufferedReader, and Scanner, and object file I/O using ObjectInputStream and ObjectOutputStream to save and load objects. It also covers using JFileChooser to allow users to select files and applying file filters.
This chapter discusses various methods of file input and output in Java, including low-level file I/O using FileInputStream and FileOutputStream, high-level file I/O using DataInputStream and DataOutputStream to read and write primitive data types, reading and writing text files using PrintWriter, BufferedReader, and Scanner, and object file I/O using ObjectInputStream and ObjectOutputStream to save and load objects. It also covers using JFileChooser to allow users to select files and applying file filters.
This document provides an overview of Java input-output (I/O) streams and classes. It discusses the core stream classes like InputStream, OutputStream, Reader, Writer and their subclasses like FileInputStream, FileOutputStream, FileReader, FileWriter. It also covers buffered stream classes like BufferedInputStream, BufferedOutputStream, BufferedReader, BufferedWriter which provide better performance. Examples are given to demonstrate reading, writing and file handling using these stream classes.
This document provides an overview of input/output operations in Java using the java.io package. It discusses streams and channels, file I/O, reading and writing files, serialization, and the Observer and Observable interfaces. The key classes covered include File, PrintWriter, Scanner, InputStream, OutputStream, Reader, Writer, Buffer, Channel, and classes for serialization. Examples are provided for reading and writing files using byte streams, character streams, buffers, and channels.
This document discusses I/O streams in Java. It defines streams as sequences of bytes that flow from a source to a destination. Streams can be categorized as character streams for text data or byte streams for raw binary data. Streams are also categorized as data streams that act as sources or destinations, or processing streams that alter or manage stream information. The Java IO package contains classes for defining input and output streams of different types.
The document discusses various Java I/O stream classes:
- FileInputStream and FileOutputStream are used for reading and writing raw bytes to files.
- InputStreamReader and OutputStreamWriter bridge byte streams to character streams using a specified character encoding.
- FileReader and FileWriter are built on top of InputStreamReader and OutputStreamWriter respectively, and are used for reading and writing character streams from files.
This document provides information on input/output operations, file handling, and serialization in Java. It discusses Java's input and output streams for reading and writing bytes and characters. It describes classes for working with files like File, FileInputStream, FileOutputStream, FileReader, and FileWriter. Examples are given for reading from and writing to files and the console. The document also introduces serialization in Java for converting objects to byte streams for storage or transmission.
This document discusses files and streams in Java. It covers key concepts like:
- Streams represent sources of input or destinations of output and support different data types.
- Input streams read data from sources one item at a time, while output streams write to destinations.
- Byte streams handle raw bytes, while character streams automatically translate character encodings.
- Common stream classes include FileInputStream, FileOutputStream, FileReader and FileWriter for file I/O.
- The predefined System streams like System.in and System.out represent standard input/output.
The document discusses streams and input/output in Java. It introduces streams as a way to represent ordered sequences of data in a uniform manner across different I/O devices. It describes the different types of streams in Java, including byte streams and character streams. It also outlines some of the key input and output stream classes in Java and common stream operations like reading, writing, skipping bytes, and closing streams.
This document discusses Java's input/output (I/O) capabilities through the java.io package. It describes the core I/O stream classes like InputStream, OutputStream, Reader and Writer. It also covers file I/O using File and FileInput/OutputStream classes. Buffered, filtered and character streams are explained. The use of serialization interfaces like Serializable and Externalizable for object I/O is summarized. The document provides examples of reading, writing and manipulating files and directories in Java.
This document provides an overview of Java I/O streams and how to open, use, and close them. It discusses how opening a stream creates a connection to external data, using a stream involves reading or writing data, and closing streams is important to release resources. It then gives examples of opening a FileReader stream, reading lines with a BufferedReader, and closing streams. The document also introduces LineReader and LineWriter classes that simplify reading and writing text files line-by-line in Java.
This document provides an overview of Java I/O streams and how to open, use, and close them. It discusses how opening a stream creates a connection to external data, using a stream involves reading or writing data, and closing streams is important to release resources. It then gives examples of opening a FileReader stream, reading lines with a BufferedReader, and includes code for a LineReader class to simplify reading text files and a LineWriter class to write text files.
The document discusses input/output streams in Java. It covers:
- Different types of data storage including transient RAM and persistent storage like disks.
- I/O sources and destinations like consoles, disks, networks etc. and how streams represent sequential bytes to abstract I/O details.
- Common Java I/O stream classes like FileReader, FileWriter, InputStream and OutputStream for reading/writing text and binary data from files.
- Using File class to represent files and directories with methods to check attributes, read content and manipulate files.
File input and output operations in Java are performed using streams. There are two types of streams - byte streams and character streams. Byte streams handle input/output at the byte level while character streams handle input/output at the character level using Unicode encoding. The File class in Java represents files and directories on the filesystem and provides methods to perform operations like creating, reading, updating and deleting files.
File Handling Presentation As well as File handling code in java Update, Delete, Search, View, Insert in file code are available in this presentation in you face some issues so contact me 03244064060 , Also in my Email: [email protected] and Twitter @azeemaj101
This document discusses Java I/O and streams. It begins by introducing files and the File class, which provides methods for obtaining file properties and manipulating files. It then discusses reading and writing files using byte streams like FileInputStream and FileOutputStream. Character streams like PrintWriter and BufferedReader are presented for console I/O. Other stream classes covered include buffered streams, object streams for serialization, and data streams for primitive types. The key methods of various stream classes are listed.
Java uses streams to handle input/output operations. Streams provide a standardized way to read from and write to various sources and sinks like files, networks, and buffers. There are byte streams that handle input/output of bytes and character streams that handle characters. Common stream classes include FileInputStream, FileOutputStream, BufferedReader, and BufferedWriter which are used to read from and write to files and console. Streams can be chained together for complex I/O processing.
This document discusses the modules, evaluation, textbook, and units for an Advanced Java course. The 5 units cover File Handling, Java Collection Framework and Event Handling, Swing and GUI Components, Networking & Database Connectivity. The internal evaluation includes 5 assignments worth 25 marks total and an MCQ test worth 25 marks. The textbook recommended is "Programming in Java2" by Dr.K.Somasundaram. Unit 1 covers File Input/Output streams, the File class, byte streams, character streams, and reading/writing files using FileInputStream, FileOutputStream, and RandomAccessFile.
This study will provide the audience with an understanding of the capabilities of soft tools such as Artificial Neural Networks (ANN), Support Vector Regression (SVR), Model Trees (MT), and Multi-Gene Genetic Programming (MGGP) as a statistical downscaling tool. Many projects are underway around the world to downscale the data from Global Climate Models (GCM). The majority of the statistical tools have a lengthy downscaling pipeline to follow. To improve its accuracy, the GCM data is re-gridded according to the grid points of the observed data, standardized, and, sometimes, bias-removal is required. The current work suggests that future precipitation can be predicted by using precipitation data from the nearest four grid points as input to soft tools and observed precipitation as output. This research aims to estimate precipitation trends in the near future (2021-2050), using 5 GCMs, for Pune, in the state of Maharashtra, India. The findings indicate that each one of the soft tools can model the precipitation with excellent accuracy as compared to the traditional method of Distribution Based Scaling (DBS). The results show that ANN models appear to give the best results, followed by MT, then MGGP, and finally SVR. This work is one of a kind in that it provides insights into the changing monsoon season in Pune. The anticipated average precipitation levels depict a rise of 300–500% in January, along with increases of 200-300% in February and March, and a 100-150% increase for April and December. In contrast, rainfall appears to be decreasing by 20-30% between June and September.
First Review PPT gfinal gyft ftu liu yrfut goSowndarya6
CyberShieldX provides end-to-end security solutions, including vulnerability assessment, penetration testing, and real-time threat detection for business websites. It ensures that organizations can identify and mitigate security risks before exploitation.
Unlike traditional security tools, CyberShieldX integrates AI models to automate vulnerability detection, minimize false positives, and enhance threat intelligence. This reduces manual effort and improves security accuracy.
Many small and medium businesses lack dedicated cybersecurity teams. CyberShieldX provides an easy-to-use platform with AI-powered insights to assist non-experts in securing their websites.
Traditional enterprise security solutions are often expensive. CyberShieldX, as a SaaS platform, offers cost-effective security solutions with flexible pricing for businesses of all sizes.
Businesses must comply with security regulations, and failure to do so can result in fines or data breaches. CyberShieldX helps organizations meet compliance requirements efficiently.
How Binning Affects LED Performance & Consistency.pdfMina Anis
🔍 What’s Inside:
📦 What Is LED Binning?
• The process of sorting LEDs by color temperature, brightness, voltage, and CRI
• Ensures visual and performance consistency across large installations
🎨 Why It Matters:
• Inconsistent binning leads to uneven color and brightness
• Impacts brand perception, customer satisfaction, and warranty claims
📊 Key Concepts Explained:
• SDCM (Standard Deviation of Color Matching)
• Recommended bin tolerances by application (e.g., 1–3 SDCM for retail/museums)
• How to read bin codes from LED datasheets
• The difference between ANSI/NEMA standards and proprietary bin maps
🧠 Advanced Practices:
• AI-assisted bin prediction
• Color blending and dynamic calibration
• Customized binning for high-end or global projects
A substation at an airport is a vital infrastructure component that ensures reliable and efficient power distribution for all airport operations. It acts as a crucial link, converting high-voltage electricity from the main grid to the lower voltages needed for various airport facilities. This essay will explore the functions, components, and importance of a substation at an airport.
Functions of an Airport Substation:
Voltage Conversion:
Substations step down high-voltage electricity to lower levels suitable for airport operations, like terminal buildings, runways, and other facilities.
Power Distribution:
They distribute electricity to various loads, including lighting, air conditioning, navigation systems, and ground support equipment.
Grid Stability:
Substations help maintain the stability of the power grid by controlling voltage levels and managing power flows.
Redundancy and Reliability:
Airports often have redundant substations or interconnected systems to ensure uninterrupted power supply, even in case of a fault.
Switching and Control:
Substations provide switching capabilities to connect or disconnect circuits, enabling maintenance and power management.
Protection:
Substations incorporate protective devices, like circuit breakers and relays, to safeguard the power system from faults and ensure safe operation.
Key Components of an Airport Substation:
Transformers: These convert high-voltage electricity to lower voltage levels.
Circuit Breakers: These devices switch circuits on or off, protecting the system from faults.
Busbars: These are large, conductive bars that distribute electricity from transformers to other equipment.
Switchgear: This includes equipment that controls the flow of electricity, such as isolators and switches.
Control and Protection Systems: These systems monitor the substation's performance, detect faults, and automatically initiate corrective actions.
Capacitors: These improve the power factor and reduce losses in the system.
Importance of Airport Substations:
Reliable Power Supply:
Substations are essential for providing reliable power to critical airport functions, ensuring safety and efficiency.
Safe and Efficient Operations:
They contribute to the safe and efficient operation of runways, terminals, and other airport facilities.
Airport Infrastructure:
Substations are an integral part of the airport's infrastructure, enabling various operations and services.
Economic Impact:
Substations support the economic activities of the airport, including passenger and cargo handling.
Modernization and Sustainability:
Modern substations incorporate advanced technologies and systems to improve efficiency, reduce energy consumption, and enhance sustainability.
In conclusion, an airport substation is a crucial component of airport infrastructure, ensuring reliable and efficient power distribution, grid stability, and safe operations.
This document provides information about the Fifth edition of the magazine "Sthapatya" published by the Association of Civil Engineers (Practicing) Aurangabad. It includes messages from current and past presidents of ACEP, memories and photos from past ACEP events, information on life time achievement awards given by ACEP, and a technical article on concrete maintenance, repairs and strengthening. The document highlights activities of ACEP and provides a technical educational article for members.
This presentation highlights project development using software development life cycle (SDLC) with a major focus on incorporating research in the design phase to develop innovative solution. Some case-studies are also highlighted which makes the reader to understand the different phases with practical examples.
David Boutry - Mentors Junior DevelopersDavid Boutry
David Boutry is a Senior Software Engineer in New York with expertise in high-performance data processing and cloud technologies like AWS and Kubernetes. With over eight years in the field, he has led projects that improved system scalability and reduced processing times by 40%. He actively mentors aspiring developers and holds certifications in AWS, Scrum, and Azure.
Impurities of Water and their Significance.pptxdhanashree78
Impart Taste, Odour, Colour, and Turbidity to water.
Presence of organic matter or industrial wastes or microorganisms (algae) imparts taste and odour to water.
Presence of suspended and colloidal matter imparts turbidity to water.
2. File
• Long-term storage of large amounts of data
• Persistent data exists a5er termina6on of program
• Files stored on secondary storage devices
– Magne6c disks
– Op6cal disks
– Magne6c tapes
• Sequen6al and random access files
2
3. File Class
• Provides useful informa6on about a file or directory
• Does not open files or process files
• To obtain or manipulate path, 6me, date,
permissions etc
• Constructor
– File(String directoryPath)
– File(String directoryPath, String fileName)
– File(File dirObj, String fileName)
• Example: FileDemo.java
3
4. Directory Class
• Directories are also files
• Contains list of files and directories
• For DirectoryisDirectory() returns true
String[] list()
– returns an array of strings that gives the files and
directories contained
File[] listFiles()
– Returns array of File objects
• Example: DirectoryDemo.java
4
5. Stream Classes
• Java views a File as a stream of bytes.
– File ends with end-of-file marker or a specific byte number
– File as a stream of bytes associated with an object.
– Java also associates streams with devices
• System.in, System.out, and System.err
– Streams can be redirected
• Stream is an abstrac6on that either produces or
consumes informa6on
5
6. Stream Classes
• Java’s stream-based I/O is built upon four
abstract classes.
– InputStream, OutputStream (for byte streams)
– Reader, Writer (for character streams)
• They form separate hierarchies
• Use the character stream classes when working
with characters or strings
• Use the byte stream classes when working with
bytes or other binary objects
6
7. Byte Stream Classes
• Byte-Stream classes are topped by InputStream and
OutputStream classes
• InputStream is an abstract class that defines Java’s
model of streaming byte input.
int available() void close() int read()
int read(byte buff[]) int read(byte buff[], int off, int num)
• OutputStream is an abstract class that defines Java’s
model of streaming byte output.
void flush() void close() void write(int b)
void write(byte buff[]) void write(byte buff[], int off, int num)
7
8. FileInputStream
• FileInputStream class creates an InputStream that
you can use to read bytes from a file
• Constructors
– FileInputStream(String filePath)
– FileInputStream(File fileObj)
• Example: FileInputStreamDemo.java
8
9. FileOutputStream
• FileOutputStream class creates an OutputStream
that you can use to write bytes to a file
• Constructors
– FileOutputStream(String filePath)
– FileOutputStream(File fileObj)
– FileOutputStream(String path, boolean append)
– FileOutputStream(File obj, boolean append)
• Example: FileOutputStreamDemo.java, FileCopyDemo.java
9
10. Character Streams
• Character Stream classes are topped by Reader and
Writer class
• Reader is an abstract class that defines Java’s model
of streaming character input
void close() int read() int read(char buff[])
int read(char buff[], int off, int num)
• Writer is an abstract class that defines Java’s model
of streaming character output
void flush() void close() void write(int ch)
void write(char buff[]) void write(char buff[], int off, int num)
void write(String s) void write(String s, int off, int num) 10
11. FileReader
• FileReader class creates a Reader that you can use to
read the contents of a file
• Constructors
– FileReader(String filePath)
– FileReader(File fileObj)
• Example: FileReaderDemo.java
11
12. FileWriter
• FileWriter class creates a Writer that you can use to
write to a file
• Constructors
– FileWriter(String filePath)
– FileWriter(File fileObj)
– FileWriter(String path, boolean append)
– FileWriter(File obj, boolean append)
• Example: FileWriterDemo.java
12
13. BufferedReader
• BufferedReader is a Reader that buffers input
• It improves performance by reducing the number of
6mes data us actually physically read from the input
stream
• Constructors
– BufferedReader(Reader reader)
– BufferedReader(Reader reader, int buffSize)
• Example: BufferedReaderDemo.java
13
14. BufferedWriter
• BufferedWriter is a Writer that buffers output
• It improves performance by reducing the number of
6mes data actually physically wricen to the output
stream
• Constructors
– BufferedWriter(Writer writer)
– BufferedWriter(Writer writer, int buffSize)
• Example: BufferedWriterDemo.java
14
15. Serializa6on
• Serializa6on is the process of wri6ng the state of an
object to a byte stream
– This is useful when you want to save the state of your
program to a persistent storage such as file
– Later these objects can be restored by using the process of
deserializa6on
• Serializa6on can be achieved by implemen6ng
Serializable interface
15
16. Object(Input/Output)Stream
• ObjectInputStream class extends the InputStream
class
• It is responsible for reading objects from a stream
• ObjectOutputStream class extends the
OutputStream class
• It is responsible for wri6ng objects to a stream
• Example: ObjectSerializaJonDemo.java
16
18. Data(Input/Output)Stream
• DataInputStream & DataOutputStream enable to
write or read primi6ve data to or from a stream
• They implement the DataOutput & DataInput
interfaces respec6vely
• Constructors
– DataOutputStream(OutputStream os)
– DataInputStream(InputStream is)
• Example: DataIODemo.java
18
19. Console
• It is used to read and write to the console
• It supplies no constructor. A Console object is
obtained by calling System.console()
• Important Methods
– prinf,
– readLine
– readPassword
• Example: ConsoleDemo.java
19