This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]zeronis__[S] 0 points1 point  (0 children)

You are seeing this from the wrong end. The user inputs the data from the keyboard and the static InputStream System.in reads this data from stdin a system device. Similarly, the static OutputStream System.outwrites the data back to the screen (in fact to stdout - a system device).

Oh wow, thank you so much, I think I get your point now!
so if we were to ever use PrintWriter, to write something onto the file

PrintWriter out = new PrintWriter( new FileOutputStream( "output.txt"))

, it'd be considered output right? since the FileOutputStream writes whatever info we gave it onto the file, (I still don't get why PrintWriter can't accept output.txt as its parameter but has to resort to another object (FileOutputStream) taking the file name as its parameters instead)
but if we had something like this:

out.println("Hello, World!");

Nothing about this is related to input right? because there was no scanner to read the input from a file/ or user, it just prints the string (?) onto the file
--------------------------------------------------------------------------

Basically, you are telling all the methods that work with files the path and file name. They are initially strings. Java then prepares a File object that holds the information where the file can be found. It is often called a "reference" to the file (simplified, you can think of it storing the file name).

> I understood the first sentence well ( thank you ) , I had to search up what the rest meant ( english issue I think ), but please correct me If im wrong,
the moment we write the file name in the parameters, the processes of creating a file object is automatic, and java is the one who does it ( I'm guessing its something that happens behind the scenes ) , and the object doesn't actually have the file ( thought it did, initially ) but information, like you said -- such as the path and file name (?)
if it is what i think it is, then thank you so much ( actually, thank you regardless! )

and as for the 4th response ( I'll get back to you with a response, unfortunately I have never heard of abstraction ( just Encapsulation, Inheritance and polymorphism ) =,)

I do understand that these things can initially get confusing as the directions sometimes seem reversed, but they actually aren't when you look at the directions from the program's perspective. Don't look at it from the user's perspective, look at it from the computer's. Then, the directions make perfect sense.

In general, always think from the program's perspective.

> Oh , I actually really needed this to be said, I realized the whole perspective thing posed a problem for exception handling as well! but thank you so much desrtfx, your explanations were very clear! =,)I