• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting a python program to Java

 
Diesel
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I generally know how to do this but there is one specific library function in Python which I would like to convert to Java and am wondering if there is an API for this or if this needs to be written.
It is the urllib.urlretrieve() function which basically downloads an HTML page. I would really like to use this function within a Java GUI and am wondering where I can find this library or what the best way to write this function, possible using network sockets and such.
Thanks
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually the java.net package has some nice classes to handle just this thing.
 
Diesel
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,
thanks so much. This worked and it works very well. Now I can get started on the GUI. Also, the Python version of this program had a time.sleep(x) which paused the program for a user-specified time. Is there any way to do this in java without using threads or should i just have it running as a thread and use thread.wait(x)?
thanks
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you mentioned a GUI I'm assuming your using SWING. If you are you can add a Timer object to your program and use that. If not, the only way I know of is to use the sleep method in Thread. Good luck
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic