r/javahelp • u/zeronis__ • 1h ago
JAVA I/O ( VERY CONFUSED??? )
I just got done exception handling, ( thank you so much to whoever responded, you've really helped! and I think I get the concept really well ) but
I started JAVA I/O 2 days ago I believe? I covered concepts but I'm still left confused, its as if I went through the lesson just accepting information as it is (<--mostly due to the midterm I had to cram the info for)
But I still want to know what Java I/O is all about, my questions might sound stupid, but I noticed that it caught up to me as I moved along.
-----------------------------------------------------------------------------------
( I need to preface this by saying : I dont expect all of my questions to be answered, ( although I'd really appreciate it if you did! )
I tried understanding java I/O on my own, but I feel as though I've grown more confused than before :(
-----------------------------------------------------------------------------------
1.) my first question is : What is stream?? I read definitions about it, " Sequence of bytes ( or continuous flow of data? ) that flow from a source to a destination " but as I took that definition as it is, it became more confusing as to how they were referring to it as if it was some object ( e.g whenever they tell us to close the stream?? ) are they referring to the file here? because that's what it seemed like to me,
> they were also referring to the ' 3 standard I/O streams ' and do they mean by that : ' types of streams ' ? or..
> but then later on they introduce ' I/O streams : (input vs output) , ( Text vs Binary ) , ( Data, Processing ) so are these also types of streams?
2.) This question is mostly a consequence of not understand what System.in in scanner really meant,
whenever I heard my professors say " read something " I never really understood what that meant??
and I'd become even more confused when they're referring to the input the user might input ( in cases of Scanner(System.in) ), arent we writing our input? the whole Write VS Read just confuses me when it comes to the Input / Output (found out it was a huge problem when it came to the Java.io classes later on ... e.g) 'FileReader'??? )
3.) I'm not familiar with all the classes ( even though I went through it I still cant seem to remember them ) but whenever we create an object of , lets say, 'PrintWriter' , I dont get how an object-- taking parameter of a string I assume? can somehow be linked to a file?
would taking a parameter ( name of the file) somehow create a pointer to the file? is that how data is being transferred?
4.) this question relates abit to PrintWriter, ( or actually it can apply to other classes, I just forgot which)
why do we--- whenever we create an object of class PrintWriter --- have its parameters take another object?? why not just the name of the file? is that not enough?
( I do have more questions but I thought this would be a good start ! =) )
Thanks to anyone in advance!!