File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Converting a python program to Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Converting a python program to Java" Watch "Converting a python program to Java" New topic
Author

Converting a python program to Java

Diesel
Greenhorn

Joined: Aug 12, 2000
Posts: 11
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

Joined: Jun 13, 2000
Posts: 3340
Actually the java.net package has some nice classes to handle just this thing.


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Diesel
Greenhorn

Joined: Aug 12, 2000
Posts: 11
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

Joined: Jun 13, 2000
Posts: 3340
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
 
 
subject: Converting a python program to Java