Search:

Type: Posts; User: Norm

Search: Search took 0.13 seconds.

  1. Replies
    24
    Views
    1,486

    Re: simulate BufferedReader's readLine()

    Do the read in only one place, not two.
    Test what was read after it is read and then decide what to do.
  2. Replies
    24
    Views
    1,486

    Re: simulate BufferedReader's readLine()

    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.
  3. Replies
    24
    Views
    1,486

    Re: simulate BufferedReader's readLine()

    Return what was read up to but not including the -1.
    Next call return the null.
  4. Replies
    24
    Views
    1,486

    Re: simulate BufferedReader's readLine()

    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
  5. Replies
    24
    Views
    1,486

    Re: simulate BufferedReader's readLine()

    Read the API doc for the read() method.
  6. Replies
    24
    Views
    1,486

    Re: simulate BufferedReader's readLine()

    Print out the int value before casting it to char, then there won't be a ? problem.
  7. Replies
    24
    Views
    1,486

    Re: simulate BufferedReader's readLine()

    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...
  8. Replies
    24
    Views
    1,486

    Re: simulate BufferedReader's readLine()

    Yes, you need to ask the teacher what the method should do and how it should do it.
  9. Replies
    24
    Views
    1,486

    Re: simulate BufferedReader's readLine()

    Why use a while loop?
  10. Replies
    24
    Views
    1,486

    Re: simulate BufferedReader's readLine()

    Can you explain your problem?
  11. Replies
    24
    Views
    1,486

    Re: simulate BufferedReader's readLine()

    Why? Is this a requirement from an instructor? Your assignment is write your own version using the read() method?
  12. Replies
    24
    Views
    1,486

    Re: simulate BufferedReader's readLine()

    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...
Results 1 to 12 of 12