Question
CLASS DIAGRAM UML NOTATION FOR THIS CODE: import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; public class test1 { public static void main(String[]
CLASS DIAGRAM UML NOTATION FOR THIS CODE:
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
public class test1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
BufferedReader standardInput = new BufferedReader(new InputStreamReader(System. in )); // input
// from
// keyboard
// using
// BufferedReader
// and
// InputStreamReader
BufferedWriter writer = new BufferedWriter(
new FileWriter("C:\\Users\\vimlashd\\Desktop\\New folder\\myData.txt")); // write disk
// using
// FileWrite
System.out.println("Enter a line of text (stop to quit), then hit enter");
boolean finishedInput = false;
while (!finishedInput) { // run loop untill user types "stop"
System.out.println(": ");
String name = standardInput.readLine(); // read input from console
// System.out.println("String input" + name);
if (name.equalsIgnoreCase("STOP")) { // validate "STOP" action
finishedInput = true;
continue;
}
// Write entered text to disk in txt file
writer.write(name); // write text entered in the disk
writer.append(System.lineSeparator()); // append new line in the file on disk
}
writer.close(); // close file after existing from program
} catch(IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started