1

I found this really simple code written in Python:

opener = urllib2.build_opener()
data=opener.open(request)
data.read(1024)
length=ord(data.read(1))*8
print data.read(length)

and I want to rewrite it in Java. Can you help me? I can't seem to find what the data.read() methods are for, Python docs really confuse me. Newbie here.

3
  • edit: yes, sorry, it was wrong. Commented Mar 10, 2011 at 12:36
  • looks like a homework assignment... otherwise it's strange that you "found" this code, don't know what it does, but need it in Java. Commented Mar 10, 2011 at 12:42
  • yes it's a homework. you got me. where do I sign? Commented Mar 10, 2011 at 12:48

1 Answer 1

3

It opens a URL for reading, reads 1 kibibyte of data and discards it, reads one byte of data, turns that byte into a number, multiplies it by 8, and reads that many more bytes.

Sign up to request clarification or add additional context in comments.

1 Comment

when you say it discards it, does the reading afterwards continue from that point? 1024? maybe that's why it's there..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.