import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class ConsoleWriterExample {
public static void main(String[] args) {
try {
// Create a BufferedWriter that writes to the console
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
// Write some text to the console
writer.write("Hello, world!");
writer.newLine();
writer.write("This is an example of writing to the console using a BufferedWriter.");
writer.newLine();
// Flush the buffer to make sure all text is written to the console
writer.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Comments
Post a Comment
If you have any doubts, please let me know.