Reading Java byte[] data stream over standard input

sapsi saptarshi.guha at gmail.com
Mon May 19 01:11:33 EDT 2008


Hello,
I am using HadoopStreaming using a BinaryInputStream. What this
basically does is send a stream of bytes (  the java type is : private
byte[] bytes) to my python program.

I have done a test like this,
while 1:
	x=sys.stdin.read(100)
	if x:
		print x
	else:
		break

Now, the incoming data is binary(though mine is actually merely ascii
text) but the output is not what is expected. I expect for e.g

all/86000/114.310.151.209.60370-121.110.5.176.113\n62485.9718
118.010.241.12 60370 128.210.5.176

However i get a 1 before all and a 4 just after \n and before the 6.

My question is : how do i read binary data(Java's byte stream) from
stdin?
Or is this actually what i'm getting?

Thanks
Sapsi



More information about the Python-list mailing list