Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For Print Stream Reading #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion PrintStreamDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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();
Expand Down