See i tested this code but i could not able to download ..i able to save the SWF file but it's not playing and even not saying that this is an invalid file.
My code goes here.
-
-
import java.io.BufferedInputStream;
-
import java.io.BufferedOutputStream;
-
import java.io.FileOutputStream;
-
import java.net.InetAddress;
-
import java.net.InetSocketAddress;
-
import java.net.Proxy;
-
import java.net.SocketAddress;
-
import java.net.URL;
-
-
/*
-
* To change this template, choose Tools | Templates
-
* and open the template in the editor.
-
*/
-
import java.net.URLConnection;
-
-
/**
-
*
-
* @author Admin
-
*/
-
public class SWfDowloader {
-
public static void main(String a[]) throws Exception{
-
String swf_path = "http://s.ytimg.com/yt/swf/watch_v8-vfl87635.swf";
-
URL swf_url = new URL(swf_path);
-
byte address[] = {(byte)144,(byte)16,(byte)192,(byte)245};
-
SocketAddress socket_address = new InetSocketAddress(InetAddress.getByAddress(address),8080);
-
Proxy proxy = new Proxy(Proxy.Type.HTTP,socket_address);
-
URLConnection url_conn = swf_url.openConnection(proxy);
-
url_conn.connect();
-
BufferedInputStream swf_in_stream = new BufferedInputStream(url_conn.getInputStream());
-
FileOutputStream swf_file = new FileOutputStream("d:/test.swf");
-
BufferedOutputStream swf_out_stream = new BufferedOutputStream(swf_file);
-
byte bytes[] = new byte[512];
-
int read_bytes = 0;
-
while((read_bytes=swf_in_stream.read(bytes))!=-1)
-
swf_out_stream.write(bytes, 0,read_bytes);
-
-
swf_in_stream.close();
-
swf_file.close();
-
swf_out_stream.close();
-
}
-
}
-
I think the part of the SWF file downloaded.you know when you play a video in Youtube then it takes time to play the full one ...but i am not sure that the whole content i am getting here .. you also try ...i also keep searching. Le's see what happens ;)