Bytes that just... disappear...

Discussion in 'Java' started by AndrewTK, May 9, 2006.

  1. AndrewTK

    AndrewTK Guest

    Hi,

    I am trying to write an input stream that also caters for the concept
    of "line"

    My class uses a BufferedInputStream for the actual reading, and I add,
    by extending, a readLine() method

    I run into a problem when trying to read bytes: (I have code at
    http://www.dcs.st-and.ac.uk/~atk1/java/BufferedStreamReader.java)

    1/ I read bytes into a buffer byte array 'minibuff'
    2/ I iterate over each byte and check for a CR, LF, or CRLF pair

    Before I enter the iteration loop, it is possible to print out the
    input received. Thereafter, the bytes don't appear to EXIST... The
    printBinaryByte() method I provide works before the for loop is
    entered, but disappears afterwards.

    I don't really know how to explain what I mean by disappears... nothing
    prints when your try to print the byte, and binary comparison yeilds
    nothing at all either... nothing prints to nowhere.

    I am very confused.
    AndrewTK, May 9, 2006
    #1
    1. Advertising

  2. AndrewTK

    Eric Sosman Guest

    AndrewTK wrote On 05/09/06 16:15,:
    > Hi,
    >
    > I am trying to write an input stream that also caters for the concept
    > of "line"
    >
    > My class uses a BufferedInputStream for the actual reading, and I add,
    > by extending, a readLine() method
    >
    > I run into a problem when trying to read bytes: (I have code at
    > http://www.dcs.st-and.ac.uk/~atk1/java/BufferedStreamReader.java)
    >
    > 1/ I read bytes into a buffer byte array 'minibuff'
    > 2/ I iterate over each byte and check for a CR, LF, or CRLF pair
    >
    > Before I enter the iteration loop, it is possible to print out the
    > input received. Thereafter, the bytes don't appear to EXIST... The
    > printBinaryByte() method I provide works before the for loop is
    > entered, but disappears afterwards.


    The loop never executes.

    int line_end = -1;
    // irrelevant stuff ...
    for(int i=0;i<r && line_end != -1;i++) {
    ^^^^^^^^^^^^^^
    equals false


    --
    Eric Sosman, May 9, 2006
    #2
    1. Advertising

  3. AndrewTK

    AndrewTK Guest

    I have had the disappearing byte problem before, I swear... In a
    different context though, so that's why I posted.

    Albeit I look very stupid now. But thanks for the tip off...!
    AndrewTK, May 10, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason Collins
    Replies:
    3
    Views:
    5,997
    Jason Collins
    Feb 18, 2004
  2. mrby

    4-bytes or 8-bytes alignment?

    mrby, Nov 2, 2004, in forum: C Programming
    Replies:
    8
    Views:
    405
    Mark McIntyre
    Nov 2, 2004
  3. Replies:
    5
    Views:
    519
    Flash Gordon
    Apr 9, 2006
  4. Yandos
    Replies:
    12
    Views:
    5,099
    Pete Becker
    Sep 15, 2005
  5. Replies:
    8
    Views:
    484
    Bob Hairgrove
    Apr 10, 2006
Loading...

Share This Page