Professional Documents
Culture Documents
1. File Class
2. Methods of File Class
3. File Write Operation
4. File Read Operation
Check the Error
1. .
2. .
3. public class File{
4. public Static void main (string [] args) {
5. File file = new File(“filename.txt”);
6. If(file.exists()) {
7. System.out.Println(“File exists”);
8. } {
9. System.out.println(“File does not exist”);
10. try {
11. file.createNewFile();
12. } catch (IOException ) {
13. e.printStackTrace();
14. }
15. }
16. }
17. }
File IO
package com.javatpoint;
import java.io.*;
public class BufferedReaderExample{
public static void main(String args[])throws Exception{
InputStreamReader r=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(r);
System.out.println("Enter your name");
String name=br.readLine();
System.out.println("Welcome "+name);
}
}
Write a program to read from a file and
write to a file.
Books
1. https://www.w3schools.com/java/java_files_create.asp