Posts

Showing posts from September, 2024

File operation

                File operation  Insert :  Adds new data to the end of the file. Select :  Reads and prints the content of the file. Update :  Reads the file, replaces occurrences of old text with new text, and writes the updated content back. Delete :  Deletes the file from the files programs.   Program : import java.io.File; import java.io.*; import java.io.FileWriter; import java.io.FileReader; import java.io.BufferedReader; import java.io.IOException; class FSC{     public static void main(String args[])throws IOException { int i; DataInputStream d = new DataInputStream(System.in); String fileName = "msc1.txt"; do { System.out.println("\nwhich type of file operation you want to perform?"); System.out.println("\n1.file creation\n2.read\n3.write\n4.update\n5.delete"); System.out.println("Enter your choice:"); i= Integer.parseInt(d.readLine()); switch(i) {   case 1:        createFile...