Download presentation
Presentation is loading. Please wait.
1
Streams, File I/O and Scanner class
Anubhav chaturvedi
3
File Descriptors an abstract indicator for accessing a file ( int )
The three standard descriptors in unistd.h: Standard Input : STDIN_FILENO Standard Output : STDOUT_FILENO Standard Error : STDERR_FILENO
4
Standard Streams
5
Let’s make life simple
6
Adding Layers of abstraction
7
The java.io package
8
EchoConsole.java example
9
CopyFile.java example
10
ExchangeStreams.java example
11
Why two constructors and how are they different?
There are two ways to initialize FileInputStream… why? FileInputStream(String name) and FileInputStream(File file)
12
Internal implementation
public FileInputStream(String name) throws FileNotFoundException { this(name != null ? new File(name) : null); }
13
Why two different classes – FileReader and FileInputStream?
Unicode Character Encoding 2 byte vs 1 byte transfer Byte stream and character stream The Readers and Writers are Character streams
14
All seems to be good so far But there is one problem…
15
IT’S NOT SIMPLE ENOUGH
16
Adding another Layer of abstraction
17
Scanner.java java.util package
More complex and useful than other available classes Abstraction level attained: Read Files and Streams Perform Regex operation Checking and getting available data types contained in the string
18
ScannerReadingFile.java example
19
Reference
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.