The document discusses I/O streams in Java. It describes that streams represent input sources and output destinations and come in two types - input streams for reading data and output streams for writing data. Standard streams like System.in and System.out are used for input and output. Various classes are used for byte streams like FileInputStream and character streams like FileReader. Methods of classes like BufferedReader, DataInputStream, Scanner, FileInputStream and FileOutputStream are explained for reading and writing data.
Computer science input and output BASICS.pptxRathanMB
Stream is a sequence of data that supports methods to read or write data. There are two types of streams in Java - byte streams and character streams. Byte streams are used for input/output of bytes while character streams are used for input/output of Unicode characters. The java.io package contains classes for input/output in Java, including abstract classes like InputStream and OutputStream for byte streams, and Reader and Writer for character streams. System.in, System.out and System.err are predefined streams for input, output and errors respectively.
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.
The document discusses input/output (I/O) in Java, including byte streams, character streams, and reading/writing to the console. It covers:
1) Byte and character streams for handling input/output of bytes and characters respectively. Character streams use Unicode for internationalization.
2) The InputStream, OutputStream, Reader, and Writer classes used for byte and character I/O.
3) Reading input from the console using a BufferedReader connected to System.in, and writing output using PrintStream/PrintWriter connected to System.out.
This document provides an overview of input/output (I/O) and threading concepts covered in Module 4 of the OODP syllabus. It discusses Java stream classes for byte and character I/O, including reading console input and working with files. It also covers the thread model in Java and using the Thread class and Runnable interface. The summary discusses I/O basics like input/output sources and destinations, and how Java represents data flows using streams. It also provides examples of using byte streams like DataInputStream and character streams like BufferedReader to perform I/O operations in Java programs.
The document discusses several key topics related to input/output (I/O) and applets in Java:
- I/O in Java is performed through streams which can be byte-based or character-based and linked to physical devices. The predefined streams System.in, System.out, and System.err are introduced.
- Reading input and writing output involves classes like BufferedReader, PrintWriter, FileInputStream and FileOutputStream.
- Applets are small Java programs that can be run in a web browser. Every applet must extend the Applet class and override the paint() method to display its graphical user interface.
The document discusses Java I/O streams, which allow programs to read and write data. It describes the different types of streams for reading bytes and characters from sources like files, pipes, and memory. It also covers serialization which allows objects to save their state to a byte stream that can later be used to recreate the object.
- Java performs I/O through streams which are abstractions that produce or consume data and are linked to physical devices.
- There are two types of streams in Java: byte streams which handle input/output of bytes and character streams which handle input/output of characters more efficiently.
- The main classes for byte streams are InputStream, OutputStream and their subclasses like FileInputStream and FileOutputStream. The main classes for character streams are Reader and Writer.
- The predefined streams System.in, System.out and System.err represent standard input, standard output and standard error streams in Java.
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.
Computer science input and output BASICS.pptxRathanMB
Stream is a sequence of data that supports methods to read or write data. There are two types of streams in Java - byte streams and character streams. Byte streams are used for input/output of bytes while character streams are used for input/output of Unicode characters. The java.io package contains classes for input/output in Java, including abstract classes like InputStream and OutputStream for byte streams, and Reader and Writer for character streams. System.in, System.out and System.err are predefined streams for input, output and errors respectively.
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.
The document discusses input/output (I/O) in Java, including byte streams, character streams, and reading/writing to the console. It covers:
1) Byte and character streams for handling input/output of bytes and characters respectively. Character streams use Unicode for internationalization.
2) The InputStream, OutputStream, Reader, and Writer classes used for byte and character I/O.
3) Reading input from the console using a BufferedReader connected to System.in, and writing output using PrintStream/PrintWriter connected to System.out.
This document provides an overview of input/output (I/O) and threading concepts covered in Module 4 of the OODP syllabus. It discusses Java stream classes for byte and character I/O, including reading console input and working with files. It also covers the thread model in Java and using the Thread class and Runnable interface. The summary discusses I/O basics like input/output sources and destinations, and how Java represents data flows using streams. It also provides examples of using byte streams like DataInputStream and character streams like BufferedReader to perform I/O operations in Java programs.
The document discusses several key topics related to input/output (I/O) and applets in Java:
- I/O in Java is performed through streams which can be byte-based or character-based and linked to physical devices. The predefined streams System.in, System.out, and System.err are introduced.
- Reading input and writing output involves classes like BufferedReader, PrintWriter, FileInputStream and FileOutputStream.
- Applets are small Java programs that can be run in a web browser. Every applet must extend the Applet class and override the paint() method to display its graphical user interface.
The document discusses Java I/O streams, which allow programs to read and write data. It describes the different types of streams for reading bytes and characters from sources like files, pipes, and memory. It also covers serialization which allows objects to save their state to a byte stream that can later be used to recreate the object.
- Java performs I/O through streams which are abstractions that produce or consume data and are linked to physical devices.
- There are two types of streams in Java: byte streams which handle input/output of bytes and character streams which handle input/output of characters more efficiently.
- The main classes for byte streams are InputStream, OutputStream and their subclasses like FileInputStream and FileOutputStream. The main classes for character streams are Reader and Writer.
- The predefined streams System.in, System.out and System.err represent standard input, standard output and standard error streams in Java.
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.
In Java, Input and Output (I/O) are used to process the input and produce the output.
This means an input stream can abstract many different input kinds: from a disk file, a keyboard, or a network socket. Likewise, an output stream may refer to the console, a disk file, or a network connection.
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 provides an overview of binary input and output (I/O) in Java. It discusses the different stream classes for reading and writing bytes and characters, including FileInputStream, FileOutputStream, DataInputStream and DataOutputStream. It also covers reading and writing primitive values, strings, and objects to binary files. RandomAccessFile is introduced for random access to files.
The document discusses Java I/O streams and collections framework. It covers byte streams, character streams, reading console input, writing console output, and reading and writing files. It also discusses different I/O stream classes like InputStream, OutputStream, Reader, Writer and their subclasses. It provides examples of reading input from the keyboard and writing output to the console using System.in, System.out and System.err streams. It also discusses reading characters and strings from the keyboard using BufferedReader class.
This document provides an overview of Java input/output programming, networking, and streams. It discusses reading input from the console and keyboard using BufferedReader, StringTokenizer, and Scanner. It also covers writing output to the console. Predefined streams like System.in and System.out are explained. The basics of character streams, byte streams, and Java streams are summarized. Networking concepts like IP addresses that enable communication between devices on a computer network are also briefly introduced.
The document discusses Java I/O streams and network programming. It provides an overview of input/output streams, readers/writers, and common stream classes in Java like FileInputStream, FileOutputStream, BufferedReader, PrintWriter and others. Key stream concepts like available(), read(), write(), close() are explained. Examples of reading from and writing to files and memory are given.
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 provides information on Java APIs, IO packages, streams, serialization, networking and TCP sockets. It defines that an API allows communication between programs, Java IO handles input/output through streams, and common IO classes include FileInputStream, FileOutputStream. Networking concepts covered include sockets, ports, IP addresses and protocols like TCP. TCP sockets in Java use Socket and ServerSocket classes.
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 (I/O) streams in Java. It describes character streams and byte streams for reading/writing data. It also covers standard I/O streams, file streams, pipe streams, filtering streams, object serialization, and random access files. The key classes for I/O streams are Readers/Writers for character data and InputStreams/OutputStreams for byte data. Standard streams include System.in, System.out, and System.err.
This document provides an overview of input/output (I/O) streams in Java, including character streams, byte streams, file streams, pipe streams, filter streams, object serialization, and random access files. It also discusses the standard input, output, and error streams in Java and how to read from and write to these streams.
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.
The document provides information about Java presentation materials on file input/output (I/O). It discusses the Path and File classes for working with file paths and names. It also covers reading and writing files using FileInputStream, FileOutputStream, FileReader, FileWriter, InputStream, OutputStream, InputStreamReader, OutputStreamWriter, serialization, and random access files. The presentation includes code examples for creating files and paths, reading and writing files, and serializing/deserializing objects.
In this tutorial, I take you through an important feature of Java: File Operations. We are going to take a look at Character and Byte Streams, some built-in Classes and their functionalities to be able to perform file operations. Then we are going to learn about a famous concept called exception handling. We are going to finalize this tutorial with Number Formatting.
Check out rest of the Tutorials: https://berksoysal.blogspot.com/2016/06/java-se-tutorials-basics-exercises.html
The document discusses Java I/O streams and input/output. It introduces streams as an ordered sequence of data linked to a physical device. Streams can represent different sources and destinations like files, devices, networks. Input streams read data from a source while output streams write data to a destination. Byte streams handle bytes and character streams handle characters. Important stream classes include InputStream, OutputStream, Reader, and Writer. The System class defines predefined input, output, and error streams. Reading input involves wrapping System.in in a BufferedReader while writing uses PrintStream.
This document discusses input/output streams, error handling, and passing command line arguments in Java. It covers the basics of reading from and writing to files, the console, and networks using input/output streams. It also discusses how to handle exceptions using try/catch blocks and how to pass command line arguments to a Java program that will be stored in the main method's String array.
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 input and output streams in Java. It describes the BufferedReader class, which reads text from a character input stream and buffers it for efficient reading. It also discusses the Scanner class in Java's util package for reading user input through the keyboard. An example program is provided that uses Scanner to read integer and float values from the user and calculate their sum.
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Dr. Vinod Kumar Kanvaria
Exploiting Artificial Intelligence for Empowering Researchers and Faculty,
International FDP on Fundamentals of Research in Social Sciences
at Integral University, Lucknow, 06.06.2024
By Dr. Vinod Kumar Kanvaria
In Java, Input and Output (I/O) are used to process the input and produce the output.
This means an input stream can abstract many different input kinds: from a disk file, a keyboard, or a network socket. Likewise, an output stream may refer to the console, a disk file, or a network connection.
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 provides an overview of binary input and output (I/O) in Java. It discusses the different stream classes for reading and writing bytes and characters, including FileInputStream, FileOutputStream, DataInputStream and DataOutputStream. It also covers reading and writing primitive values, strings, and objects to binary files. RandomAccessFile is introduced for random access to files.
The document discusses Java I/O streams and collections framework. It covers byte streams, character streams, reading console input, writing console output, and reading and writing files. It also discusses different I/O stream classes like InputStream, OutputStream, Reader, Writer and their subclasses. It provides examples of reading input from the keyboard and writing output to the console using System.in, System.out and System.err streams. It also discusses reading characters and strings from the keyboard using BufferedReader class.
This document provides an overview of Java input/output programming, networking, and streams. It discusses reading input from the console and keyboard using BufferedReader, StringTokenizer, and Scanner. It also covers writing output to the console. Predefined streams like System.in and System.out are explained. The basics of character streams, byte streams, and Java streams are summarized. Networking concepts like IP addresses that enable communication between devices on a computer network are also briefly introduced.
The document discusses Java I/O streams and network programming. It provides an overview of input/output streams, readers/writers, and common stream classes in Java like FileInputStream, FileOutputStream, BufferedReader, PrintWriter and others. Key stream concepts like available(), read(), write(), close() are explained. Examples of reading from and writing to files and memory are given.
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 provides information on Java APIs, IO packages, streams, serialization, networking and TCP sockets. It defines that an API allows communication between programs, Java IO handles input/output through streams, and common IO classes include FileInputStream, FileOutputStream. Networking concepts covered include sockets, ports, IP addresses and protocols like TCP. TCP sockets in Java use Socket and ServerSocket classes.
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 (I/O) streams in Java. It describes character streams and byte streams for reading/writing data. It also covers standard I/O streams, file streams, pipe streams, filtering streams, object serialization, and random access files. The key classes for I/O streams are Readers/Writers for character data and InputStreams/OutputStreams for byte data. Standard streams include System.in, System.out, and System.err.
This document provides an overview of input/output (I/O) streams in Java, including character streams, byte streams, file streams, pipe streams, filter streams, object serialization, and random access files. It also discusses the standard input, output, and error streams in Java and how to read from and write to these streams.
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.
The document provides information about Java presentation materials on file input/output (I/O). It discusses the Path and File classes for working with file paths and names. It also covers reading and writing files using FileInputStream, FileOutputStream, FileReader, FileWriter, InputStream, OutputStream, InputStreamReader, OutputStreamWriter, serialization, and random access files. The presentation includes code examples for creating files and paths, reading and writing files, and serializing/deserializing objects.
In this tutorial, I take you through an important feature of Java: File Operations. We are going to take a look at Character and Byte Streams, some built-in Classes and their functionalities to be able to perform file operations. Then we are going to learn about a famous concept called exception handling. We are going to finalize this tutorial with Number Formatting.
Check out rest of the Tutorials: https://berksoysal.blogspot.com/2016/06/java-se-tutorials-basics-exercises.html
The document discusses Java I/O streams and input/output. It introduces streams as an ordered sequence of data linked to a physical device. Streams can represent different sources and destinations like files, devices, networks. Input streams read data from a source while output streams write data to a destination. Byte streams handle bytes and character streams handle characters. Important stream classes include InputStream, OutputStream, Reader, and Writer. The System class defines predefined input, output, and error streams. Reading input involves wrapping System.in in a BufferedReader while writing uses PrintStream.
This document discusses input/output streams, error handling, and passing command line arguments in Java. It covers the basics of reading from and writing to files, the console, and networks using input/output streams. It also discusses how to handle exceptions using try/catch blocks and how to pass command line arguments to a Java program that will be stored in the main method's String array.
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 input and output streams in Java. It describes the BufferedReader class, which reads text from a character input stream and buffers it for efficient reading. It also discusses the Scanner class in Java's util package for reading user input through the keyboard. An example program is provided that uses Scanner to read integer and float values from the user and calculate their sum.
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Dr. Vinod Kumar Kanvaria
Exploiting Artificial Intelligence for Empowering Researchers and Faculty,
International FDP on Fundamentals of Research in Social Sciences
at Integral University, Lucknow, 06.06.2024
By Dr. Vinod Kumar Kanvaria
A workshop hosted by the South African Journal of Science aimed at postgraduate students and early career researchers with little or no experience in writing and publishing journal articles.
Executive Directors Chat Leveraging AI for Diversity, Equity, and InclusionTechSoup
Let’s explore the intersection of technology and equity in the final session of our DEI series. Discover how AI tools, like ChatGPT, can be used to support and enhance your nonprofit's DEI initiatives. Participants will gain insights into practical AI applications and get tips for leveraging technology to advance their DEI goals.
বাংলাদেশের অর্থনৈতিক সমীক্ষা ২০২৪ [Bangladesh Economic Review 2024 Bangla.pdf] কম্পিউটার , ট্যাব ও স্মার্ট ফোন ভার্সন সহ সম্পূর্ণ বাংলা ই-বুক বা pdf বই " সুচিপত্র ...বুকমার্ক মেনু 🔖 ও হাইপার লিংক মেনু 📝👆 যুক্ত ..
আমাদের সবার জন্য খুব খুব গুরুত্বপূর্ণ একটি বই ..বিসিএস, ব্যাংক, ইউনিভার্সিটি ভর্তি ও যে কোন প্রতিযোগিতা মূলক পরীক্ষার জন্য এর খুব ইম্পরট্যান্ট একটি বিষয় ...তাছাড়া বাংলাদেশের সাম্প্রতিক যে কোন ডাটা বা তথ্য এই বইতে পাবেন ...
তাই একজন নাগরিক হিসাবে এই তথ্য গুলো আপনার জানা প্রয়োজন ...।
বিসিএস ও ব্যাংক এর লিখিত পরীক্ষা ...+এছাড়া মাধ্যমিক ও উচ্চমাধ্যমিকের স্টুডেন্টদের জন্য অনেক কাজে আসবে ...
How to Add Chatter in the odoo 17 ERP ModuleCeline George
In Odoo, the chatter is like a chat tool that helps you work together on records. You can leave notes and track things, making it easier to talk with your team and partners. Inside chatter, all communication history, activity, and changes will be displayed.
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...PECB
Denis is a dynamic and results-driven Chief Information Officer (CIO) with a distinguished career spanning information systems analysis and technical project management. With a proven track record of spearheading the design and delivery of cutting-edge Information Management solutions, he has consistently elevated business operations, streamlined reporting functions, and maximized process efficiency.
Certified as an ISO/IEC 27001: Information Security Management Systems (ISMS) Lead Implementer, Data Protection Officer, and Cyber Risks Analyst, Denis brings a heightened focus on data security, privacy, and cyber resilience to every endeavor.
His expertise extends across a diverse spectrum of reporting, database, and web development applications, underpinned by an exceptional grasp of data storage and virtualization technologies. His proficiency in application testing, database administration, and data cleansing ensures seamless execution of complex projects.
What sets Denis apart is his comprehensive understanding of Business and Systems Analysis technologies, honed through involvement in all phases of the Software Development Lifecycle (SDLC). From meticulous requirements gathering to precise analysis, innovative design, rigorous development, thorough testing, and successful implementation, he has consistently delivered exceptional results.
Throughout his career, he has taken on multifaceted roles, from leading technical project management teams to owning solutions that drive operational excellence. His conscientious and proactive approach is unwavering, whether he is working independently or collaboratively within a team. His ability to connect with colleagues on a personal level underscores his commitment to fostering a harmonious and productive workplace environment.
Date: May 29, 2024
Tags: Information Security, ISO/IEC 27001, ISO/IEC 42001, Artificial Intelligence, GDPR
-------------------------------------------------------------------------------
Find out more about ISO training and certification services
Training: ISO/IEC 27001 Information Security Management System - EN | PECB
ISO/IEC 42001 Artificial Intelligence Management System - EN | PECB
General Data Protection Regulation (GDPR) - Training Courses - EN | PECB
Webinars: https://pecb.com/webinars
Article: https://pecb.com/article
-------------------------------------------------------------------------------
For more information about PECB:
Website: https://pecb.com/
LinkedIn: https://www.linkedin.com/company/pecb/
Facebook: https://www.facebook.com/PECBInternational/
Slideshare: http://www.slideshare.net/PECBCERTIFICATION
Walmart Business+ and Spark Good for Nonprofits.pdfTechSoup
"Learn about all the ways Walmart supports nonprofit organizations.
You will hear from Liz Willett, the Head of Nonprofits, and hear about what Walmart is doing to help nonprofits, including Walmart Business and Spark Good. Walmart Business+ is a new offer for nonprofits that offers discounts and also streamlines nonprofits order and expense tracking, saving time and money.
The webinar may also give some examples on how nonprofits can best leverage Walmart Business+.
The event will cover the following::
Walmart Business + (https://business.walmart.com/plus) is a new shopping experience for nonprofits, schools, and local business customers that connects an exclusive online shopping experience to stores. Benefits include free delivery and shipping, a 'Spend Analytics” feature, special discounts, deals and tax-exempt shopping.
Special TechSoup offer for a free 180 days membership, and up to $150 in discounts on eligible orders.
Spark Good (walmart.com/sparkgood) is a charitable platform that enables nonprofits to receive donations directly from customers and associates.
Answers about how you can do more with Walmart!"
This presentation includes basic of PCOS their pathology and treatment and also Ayurveda correlation of PCOS and Ayurvedic line of treatment mentioned in classics.
Main Java[All of the Base Concepts}.docxadhitya5119
This is part 1 of my Java Learning Journey. This Contains Custom methods, classes, constructors, packages, multithreading , try- catch block, finally block and more.
This presentation was provided by Steph Pollock of The American Psychological Association’s Journals Program, and Damita Snow, of The American Society of Civil Engineers (ASCE), for the initial session of NISO's 2024 Training Series "DEIA in the Scholarly Landscape." Session One: 'Setting Expectations: a DEIA Primer,' was held June 6, 2024.
2. I/O Streams
The java.io package contains nearly every class we might ever need to perform
input and output (I/O) in Java
An I/O Stream represents an input source or an output destination.
A stream can represent many different kinds of sources and destinations,
including disk files, devices, other programs, and memory arrays.
A stream can be defined as a sequence of data. There are two kinds of Streams
−
• InPutStream − The InputStream is used to read data from a source.
• OutPutStream − The OutputStream is used for writing data to a destination.
3.
4. Reading information into a program.
A program uses an input stream to read data from a source,
one item at a time:
5. Writing information from a program.
A program uses an output stream to write data to
a destination, one item at time:
6. Standard Streams
Java provides the following three standard streams −
• Standard Input − This is used to feed the data to user's program and usually a
keyboard is used as standard input stream and represented as System.in.
• Standard Output − This is used to output the data produced by the user's
program and usually a computer screen is used for standard output stream and
represented as System.out.
A list of the various print functions that we use to output statements
print():This method in Java is used to display a text on the console. This text is
passed as the parameter to this method in the form of String. This method
prints the text on the console and the cursor remains at the end of the text at
the console. The next printing takes place from just here.
Syntax: System.out.print(parameter);
7. println(): This method in Java is also used to display a text on the console.
It prints the text on the console and the cursor moves to the start of the
next line at the console. The next printing takes place from the next line.
Syntax:System.out.println(parameter);
printf():This is the easiest of all methods as this is similar to printf in C.
Note that System.out.print() and System.out.println() take a single
argument, but printf() may take multiple arguments. This is used to
format the output in Java.
System.out.printf("Formatted to "+ "specific width: n = %.4fn", // this
will print it up to // 2 decimal places);
8. System.err: This is the standard error stream that is used to output
all the error data that a program might throw, on a computer screen
or any standard output device. This stream also uses all the 3
functions to output the error data
• print()
• println()
• printf()
9. Types of Streams
Depending on the type of operations, streams can be divided into two primary classes:
• Input Stream : These streams are used to read data that must be taken as an input from a source
array or file or any peripheral device. For eg., FileInputStream, BufferedInputStream,
ByteArrayInputStream etc.
10. • Output Stream: These streams are used to write data as outputs into
an array or file or any output peripheral device. For eg.,
FileOutputStream, BufferedOutputStream,
ByteArrayOutputStream etc.
11. Depending on the types of file, Streams can be divided into two
primary classes ByteStream and CharacterStream
ByteStream: This is used to process data byte by byte (8 bits).
Though it has many classes, the FileInputStream and the
FileOutputStream are the most popular ones. The
FileInputStream is used to read from the source and
FileOutputStream is used to write to the destination.
CharacterStream: This stream is used to perform input and
output for 16-bit unicode. Though there are many classes
related to character streams but the most frequently used
classes are, FileReader and FileWriter.
12. VARIOUS BYTESTREAM CLASSES
BufferedInputStream
This class provides methods to read raw bytes from the buffer.
DataInputStream
It contains method for reading java standard datatypes.
FileInputStream
This class provides methods to read bytes from the file.
InputStream
This is an abstract class that describes stream input.
PrintStream
This contains the most used print() and println() method
13. BufferedOutputStream
This is used for Buffered Output Stream.
DataOutputStream
This contains method for writing java standard data types.
FileOutputStream
This is used to write to a file.
OutputStream
This is an abstract class that describe stream output.
15. VARIOUS CHARACTERSTREAM CLASSES
BufferedReader
It is used to handle buffered input stream, reads characters (text).
FileReader
This is an input stream that reads from file.
InputStreamReader
This input stream is used to translate byte to character.
OutputStreamReader
This output stream is used to translate character to byte.
Reader
This is an abstract class that define character stream input.
16. PrintWriter
This contains the most used print() and println() method
Writer
This is an abstract class that define character stream output.
BufferedWriter
This is used to handle buffered output stream.
FileWriter
This is used to output stream that writes to file.
17. BufferedReader
• Java Reader is an abstract class for reading character streams. The
Java BufferedReader class is a subclass of the Java Reader class
• The Java BufferedReader class, java.io.BufferedReader, provides buffering for our
Java Reader instances.
• Java BufferedReader reads a larger block (array) at a time.
• The Java BufferedReader is similar to the BufferedInputStream but they are not exactly the
same.
• The main difference between BufferedReader and BufferedInputStream is
that BufferedReader reads characters(text), whereas the BufferedInputStream reads raw
bytes.
18. The BufferedReader class of Java is used to read the stream of characters from the specified source
(character-input stream). The constructor of this class accepts an InputStream object as a parameter.
This class provides methods named read() and readLine() which reads and returns the character
and next line from the source (respectively) and returns them.
• Instantiate an InputStreamReader class bypassing your InputStream object as a parameter.
• Then, create a BufferedReader, bypassing the above obtained InputStreamReader object as a
parameter.
• Now, read data from the current reader as String using the readLine() or read() method.
BufferedReader reader =new BufferedReader(new InputStreamReader(System.in));
System.in is an InputStream which is typically connected to keyboard input of console programs.
19. DataInputStream Class
Java DataInputStream class allows an application to read primitive data (int, float, long etc.)from the
input stream in a machine-independent way.
Declaration for java.io.DataInputStream class
public class DataInputStream extends FilterInputStream implements DataInput
Wrap an InputStream in a DataInputStream and then you can read Java primitives via
the DataInputStream.
That is why it is called DataInputStream - because it reads data (numbers) instead of just bytes.
Create a DataInputStream
We create a Java DataInputStream via its constructor.
Pass an InputStream as parameter from which the primitive data types are to be read
20. DataInputStream dataInputStream = new DataInputStream( new
FileInputStream("data/data.bin"));
1.First a DataInputStream is created with a FileInputStream as source for its data.
2. Java primitives are read from the DataInputStream.
21. Java DataInputStream class Methods
Method Description
int read(byte[] b) It is used to read the number of bytes
from the input stream.
int read(byte[] b, int off, int len) It is used to read len bytes of data
from the input stream.
int readInt() It is used to read input bytes and
return an int value.
byte readByte() It is used to read and return the one
input byte.
char readChar() It is used to read two input bytes and
returns a char value.
22. double readDouble() It is used to read eight input bytes and
returns a double value.
boolean readBoolean()
It is used to read one input byte and
return true if byte is non zero, false if
byte is zero.
int skipBytes(int x)
It is used to skip over x bytes of data
from the input stream.
String readUTF() It is used to read a string that has been
encoded using the UTF-8 format.
void readFully(byte[] b)
It is used to read bytes from the input
stream and store them into the
buffer array.
23. Difference between DataInputStream and BufferedReader
• The DataInputStream works with the binary data, while the BufferedReader work with
character data.
• DataInputStream is a kind of InputStream to read data directly as primitive data types.
• BufferedInputStream is a kind of inputStream that reads data from a stream and uses a
buffer to optimize speed access to data.
• DataInputStream consumes less amount of memory space being it is binary stream, where
as BufferedReader consumes more memory space being it is character stream.
• The data to be handled is limited in DataInputStream, where as the number of characters to
be handled has wide scope in BufferedReader.
24. • All primitive data types can be handled by using the corresponding methods in
DataInputStream class, while only string data can be read from BufferedReader class and they
need to be parsed into the respective primitives.
25. Scanner Class in Java
• The Scanner class is used to get user input, and it is found in the java.util package.
• It is used for obtaining the input of the primitive types like int, double, etc. and
strings.
• To create an object of Scanner class, we usually pass the predefined object System.in, which
represents the standard input stream. We may pass an object of class File if we want to read input
from a file. A Scanner breaks its input into tokens using a delimiter pattern.
• The resulting tokens may then be converted into values of different types using the
various next methods.
For example, this code allows a user to read a number from System.in:
Scanner sc = new Scanner(System.in);
• You can declare scanner type object say ‘sc’
• The Scanner class constructor, which takes an InputStream object (i.e., System.in) as a parameter. The
System.in specifies the standard console keyboard input.
26. Input Types
Method Description
nextBoolean() Reads a boolean value from the user
nextByte() Reads a byte value from the user
nextDouble() Reads a double value from the user
nextFloat() Reads a float value from the user
nextInt() Reads a int value from the user
nextLine() Reads a String value from the user
nextLong() Reads a long value from the user
nextShort() Reads a short value from the user
27. Difference between Scanner and BufferedReader
• Scanner class can be used for user input by importing from java.util package.
• BufferedReader class can be used by importing from java.io package.
• Buffered Reader reads the input and buffers it.
• It hasn’t multiple functions like reading integer or character or long.
• Buffered reader just reads a line.
• Scanner on the other hand is formatted input.
• It has ability to read character, integer, long, etc.
• It reads the input and processes it accordingly.
• Scanner class uses regular expression in parsing the strings, by default, white space gets set as a delimiter,
but you can set any other delimiter.
• Scanner is slower than BufferedReader
28. FileInputStream Class
• The FileInputStream class of the java.io package can be used to read contents of a file as a stream of bytes.
• The Java FileInputStream class is a subclass of Java InputStream.
• To read the contents from the file, first make an object of FileInputStream class and specify the file name as an
argument to the constructor:
1. Using the path to file
FileInputStream input = new FileInputStream(StringPath);
2. Using an object of the file
FileInputStream input = new FileInputStream(File fileObject);
29. Methods of FileInputStream
• read() - reads a single byte from the file
• read(byte[] array) - reads the bytes from the file and stores in the specified array
• read(byte[] array, int start, int length) - reads the number of bytes equal to length from
the file and stores in the specified array starting from the position start
• available()-To get the number of available bytes, we can use the available() method.
30. Convert FileInputStream to Reader
• The Java FileInputStream is a byte based stream of data.
• We can convert a Java FileInputStream to a Java Reader using the Java
InputStreamReader.
• The Java InputStreamReader class is thus a subclass of the Java Reader class.
• InputStreamReader class, wraps a Java InputStream, thereby turning the byte
based InputStream into a character based Reader.
• The Java InputStreamReader is often used to read characters from file
Example
InputStream inputStream = new FileInputStream("c:datainput.txt"); Reader
inputStreamReader = new InputStreamReader(inputStream);
First creates a FileInputStream and then wraps it in an InputStreamReader. Second, the
31. FileOutputStream in Java
• The FileOutputStream class of the java.io package can be used to write data (in bytes)
to the files. In order to create a file output stream, we must import
the java.io.FileOutputStream package first.
we can create a file output stream in Java
• 1. Using the path to file
FileOutputStream output = new FileOutputStream(String path);
• 2. Using an object of the file
FileOutputStream output = new FileOutputStream(File fileObject);
32. Methods of FileOutputStream
• write() - writes the single byte to the file output stream
• write(byte[] array) - writes the bytes from the specified array to the output stream
• write(byte[] array, int start, int length) - writes the number of bytes equal to length to
the output stream from an array starting from the position start
• getBytes() -converts a string into an array of bytes.
• flush() -To clear the output stream, we can use the flush() method. This method forces
the output stream to write all data to the destination.
• close()-It is used to closes the file output stream.