Bytes that just... disappear...

A

AndrewTK

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.
 
E

Eric Sosman

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
 
A

AndrewTK

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...!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,850
Latest member
VMRKlaus8

Latest Threads

Top