Do the read in only one place, not two.
Test what was read after it is read and then decide what to do.
Type: Posts; User: Norm
Do the read in only one place, not two.
Test what was read after it is read and then decide what to do.
rewrite the code to read into an int and work with its value: cast and concatenate or whatever needs to be done.
Don't make so many tests and casts.
Return what was read up to but not including the -1.
Next call return the null.
That value says there is no more data. Time to return a null.
I don't know what that means?
The read() method has nothing to do with Strings or indexes. It reads bytes or chars
Read the API doc for the read() method.
Print out the int value before casting it to char, then there won't be a ? problem.
Try debugging the code by printing out the value returned by each call to the read() method so you can see what the computer sees when it executes the code. Be sure to use a small file with a few...
Yes, you need to ask the teacher what the method should do and how it should do it.
Why use a while loop?
Can you explain your problem?
Why? Is this a requirement from an instructor? Your assignment is write your own version using the read() method?
That is what the method is defined to do. What do you want your method to return when it finds end of file?
I'm not sure I understand your problem. null at end of file is easy to test for. Any...