/ Published in: Python

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
package get.file.example; import java.io.BufferedInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; public class GetFileExample { public GetFileExample() { try { byte[] bite = new byte[2048]; int read; URL url = new URL("http://switch.dl.sourceforge.net/sourceforge/pys60miniapps/FlickrS60_src_v0.1b.tar.bz2"); BufferedInputStream bis = new BufferedInputStream(url.openStream()); FileOutputStream fos = new FileOutputStream("/tmp/file.tar.bz2"); while((read = bis.read(bite))>0) { fos.write(bite, 0, read); System.out.println("--"); } fos.close(); bis.close(); System.out.println("FINE"); } catch(MalformedURLException e) { e.printStackTrace(); } catch(IOException e) { e.printStackTrace(); } } public static void main(String[] args) { new GetFileExample(); } }
Comments
