File Handling in Java
Student will be able to:
- Describe the concept of an I/O stream
- Explain the difference between text files and binary files
- Save data
- Read data
The character input and output shown so far has used the pre-defined “standard” streams System.in and System.out. Obviously in many real applications it is necessary to access named files. In many programming languages there is a logical (and practical) distinction made between files that will contain text and those while will be used to hold binary information. Files processed as binary are thought of as sequences of 8- bit bytes, while ones containing text model sequences of characters.
Java uses names typically based on the word Stream for binary access, and Reader and Writer for text. So when you read the documentation expect to find two broadly parallel sets of mechanisms, one for each style of access.
creates InputStreamReader to read standard input stream until the user types a “q”.
Write a java program to demonstrate InputStream and OutputStream
A java program to show that a method called to read characters, and that it returns the integer -1 at end of file.
Write a java program by using list( ) method provided by File object to list down all the files and directories available in a directory.
Write a java program to compare paths of two files?
Write a java program to create a new file?
Write a java program to create a new file (another way)?
Write a java program to get last modification date of a file?
Write a java program to create a file in a specified directory?
Write a java program to check a file exist or not?
Write a java program to make a file read-only?
Write a java program to rename a file?