java 5
java 5
(Professional Elective-1)
Course Code:125BK
• The Java Collections Framework (java.util package) is a core library that provides
efficient and flexible data structures for handling and manipulating collections of
objects.
• This framework includes several classes and interfaces for data storage and retrieval,
making it a powerful tool for organizing and managing data in Java applications.
Stream based I/O (java.io)
The Collections Framework (java.util)
➢ In java, the IO operations are performed using the concept of streams.
➢ Generally, a stream means a continuous flow of data.
➢ In java, a stream is a logical container of data that allows us to read from and write
to it.
➢ A stream can be linked to a data source, or data destination, like a console, file or
network connection by java IO system.
➢ The stream-based IO operations are faster than normal IO operations.
➢ The Stream is defined in the java.io package
➢ In java, the stream-based IO operations are performed using two separate
streams - input stream and output stream.
➢ The java stream is composed of bytes.
Stream based I/O (java.io)
The Collections Framework (java.util)
Source Destination
File
File
Socket Socket
I/O Stream Hierarchy
IOStreams
ByteStream CharacterStream
Socket
CharacterStream Classes
Socket
Java Predefined streams
• System contains predefined Stream variables in, out and err.
Socket
• These fields are declared as public and static
Reading Strings
• To read a string from BufferedReader, use readLine().
Writing Console Output
Writing console output:
• Console output is accomplished Socket
by print() and println().
• These methods are defined by the PrintStream class (referenced by System.out).
• PrintStream also implements low-level method write().
PrintWriter class
• PrintWriter is a character-based class.
• Using a PrintWriter makes real-world applications easier to internationalize.
PrintWriter pw = new PrintWriter(System.out,true)
• First argument is the OutputStream object
Text Books:
1. Herbert Schildt, Java: The Complete Reference, 10th Edition, McGraw Hill Education (India) Pvt. Ltd.
2. Herbert Schildt and Dale Skrien, Java Fundamentals - A Comprehensive Introduction, McGraw Hill Education
(India) Pvt. Ltd., 2013.
Reference Books:
1. Jaime Nino and Frederick. A. Hosch, An Introduction to Programming and Object-Oriented Design using Java, John
Wiley & sons, 2013.
2. Timothy Budd, Understanding Object-Oriented Programming with Java, updated Edition, Pearson Education.
3. Y. Daniel Liang, Introduction to Java Programming, Comprehensive Version, 7th Edition, Pearson Education.
4. H.M. Dietel and Dietel, Java – How to Program, 6th Edition, Pearson Education/PHI.
5. Cay Horstmann, Big Java, 4th Edition, John Wiley and Sons Publisher, 2009.
Online Resources:
1. https://docs.oracle.com/javase/tutorial/java/TOC.html
2. https://onlinecourses.nptel.ac.in/noc22_cs47/preview
3. www.javatpoint.com/java-tutorial
Happy journey with
JAVA Programming