Section-C (Choose the correct Answers) (1 x 2 = 2 4. Program to create a file using file writer in Blue-J. [str, si impo
Posted: Fri May 20, 2022 9:52 am
Section-C (Choose the correct Answers) (1 x 2 = 2 4. Program to create a file using file writer in Blue-J. [str, si import java.io.FileWriter; import java.io. [OlException, IOException] public class CreateFile { public static void main(String[] args) throws IOException { // Accept a string String = "File Handling in Java using "+" File Writer and FileReader"; // attach a file to File Writer File Writer fw= FileWriter("output.txt"); [old, new] // read character wise from string and write // into FileWriter for (int i = 0; i < str.length(); i++) fw.write(str.charAt(i)); System.out.println("Writing successful"); //close the file fw. LO; [open, close] } }