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.
unholysampler
17.4k7 gold badges51 silver badges65 bronze badges
-
edit: yes, sorry, it was wrong.user584513– user5845132011年03月10日 12:36:51 +00:00Commented 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.webjunkie– webjunkie2011年03月10日 12:42:29 +00:00Commented Mar 10, 2011 at 12:42
-
yes it's a homework. you got me. where do I sign?user584513– user5845132011年03月10日 12:48:14 +00:00Commented Mar 10, 2011 at 12:48
1 Answer 1
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.
answered Mar 10, 2011 at 12:40
Ignacio Vazquez-Abrams
804k160 gold badges1.4k silver badges1.4k bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
user584513
when you say it discards it, does the reading afterwards continue from that point? 1024? maybe that's why it's there..
default