JAVA Q2: Write a program that reads strings from the user and writes them to an output file called userStrings.txt. Stop processing when the user enters the string \"DONE\". Do not write the sentinel string (\"DONE\") to the output file. [15 points] Hint: For a complete example of file IO, please see the attached TestData program. Sample Output: A string. Another string. Yet more text... DONE Solution Answer import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.Scanner; class WriteStringFile { public static void main(String[] args) { File file = new File(\"D:/userFile.txt\"); String data; Scanner input = new Scanner(System.in); data = input.readLine(); try (FileOutputStream fop = new FileOutputStream(file)) { // if file doesn\'t exists, then create it if (!file.exists()) { file.createNewFile(); } if (data != \"DONE\") { // get the content in bytes byte[] contentInBytes = content.getBytes(); fop.write(contentInBytes); fop.flush(); fop.close(); } else { System.out.println(\"User Enter the value Done.. So unable to write into file\"); } } catch (IOException e) { e.printStackTrace(); } } } .