If you check the Java API for InputStream, you'll see that the 'return' value for InputStream.read(byte[], int, int) is described as:
the total number of bytes read into the buffer, or -1 if there is
no more data because the end of the stream has been reached.
So, no. You're reading one byte and storing into byteArray[0]. OneByte will be -1, 0 or 1. Breaking your loop will not work in this scenario. But, for the record, if you really only need one byte at a time, the InputStream.read() method will do the trick.
You also, for readability's sake, may want to check against the exact character you're looking for. So:
while (stream.read()!='|'){
//stuff
}
This way, anyone who reads your code (future coders, graders, etc.) will immediately know "Oh, it breaks on a Pipe Character".