IO Programming
IO Programming
Unit-09
IO Programming
File class
Stream
Byte Stream
Character Stream
File class
Java File class represents the files and directory pathnames in an abstract manner. This
class is used for creation of files and directories, file searching, file deletion etc.
The File object represents the actual file/directory on the disk. Below given is the list of
constructors to create a File object.
Constructors :
Sr. Constructor
1 File(String pathname)
Creates a new File instance by converting the given pathname string into an abstract pathname.
2 File(String parent, String child)
Creates a new File instance from a parent pathname string and a child pathname string.
3 File(URI uri)
Creates a new File instance by converting the given file: URI into an abstract pathname.
class BufferedReaderDemo {
public static void main(String[] args) throws IOException {
FileReader fr = new FileReader("input.txt");
BufferedReader br = new BufferedReader(fr);
char c[] = new char[20];
br.skip(8);
if (br.ready()) {
System.out.println(br.readLine());
br.read(c);
for (int i = 0; i < 20; i++) {
System.out.print(c[i]);
}
}
}
}