From 3ac4910039b092d4a7a513a0ddf4a63cadc70029 Mon Sep 17 00:00:00 2001 From: Mrinmoy Kar <73730091+mrinmoycyber@users.noreply.github.com> Date: Fri, 28 May 2021 00:58:00 +0530 Subject: [PATCH] For Print Stream Reading --- PrintStreamDemo.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/PrintStreamDemo.java b/PrintStreamDemo.java index f717eed..b3aeb8f 100644 --- a/PrintStreamDemo.java +++ b/PrintStreamDemo.java @@ -12,6 +12,15 @@ class Student public class PrintStreamDemo { + + /** + * + * @param args + * @throws Exception + * Student1.txt is a file upon that FileOutputStream is attached. And upon that PrintStream attach. So the 'ps' is an object of stream. + * So, whatever I write inside the stream object will go in the FileOutputStream and that will go into Student1.txt file. + */ + public static void main(String[] args) throws Exception { FileOutputStream fos=new FileOutputStream("C:\\MyJava\\Student1.txt"); @@ -23,9 +32,10 @@ public static void main(String[] args) throws Exception s.name="John"; s.dept="CSE"; + // For write it in PrintStream. So, that it will go into the stu.txt file. ps.println(s.rollno); ps.println(s.name); - ps.println(s.dept); + ps.println(s.dept); // OUTPUT -> Remember it has return three Strings [ 10, John, CSE ] ps.close(); fos.close();