Why do you think the Java language chooses to treat file data as a stream rather than as a single object? What are the benefits of this approach?
Consider loading a 4 GB file into your application as an object....
If thats not good enough consider handling 50 of those files simultanously and think about how much memory that would require.
Btw there is a high level File class for doing high level operations.
The answer depends on how you define "a stream" and a "single object".
Assuming that random access is what distinguishes the two, the answer is that the abstraction of streams is more general and supports not only disk files, but also sockets, pipes and other communication channels.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With