Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

java.io.FileInputStream read() method

OrhanCemalDuruApr 1 2018 — edited Jul 31 2018

Just to vendor a thought, I wonder why the read methods of FileInputStream do not return a boolean value. Let me describe:

The description of  read(byte[], offset, length) states that it returns an integer, switching two cases:

"the total number of bytes read into buffer, or -1 if there is no more data because the eof is reached."

What if the array length is not reached after eof? The first thing that comes to my mind is that it should throw an exception, because the allocated memory of byte array is not fulfilled.

Say it returns -1 for not throwing an exception, then the byte array is full. What's the point of returning that value (the total number of bytes) which is array.length?

This post has been answered by unknown-7404 on Apr 5 2018
Jump to Answer

Comments

mNem
Answer

did you try right-click on the project name from Projects panel and Copy ... option?

Marked as Answer by OTG-467455 · Sep 27 2020
mNem

If I were you, for "exploring different scenarios", I would just stick with creating a new class (copy the existing one if you like) and make modifications all in the same project (instead of cloning the entire project).

HTH.

OTG-467455

Hi mNem,  Both of your suggestions are good.  I just wanted to create a replica, mess around and then drop it.  So the clone works just right for me.  Thanks for your quick thinking.

1 - 3
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 11 2018
Added on Apr 1 2018
5 comments
2,667 views