Sabtu, 30 Oktober 2010

DOWNLOAD SCRIPT DARI INTERNET

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
public static void main(String args[]) throws Exception {

//Alamat yang akan kita download
URL url = new URL("http://www.google.com");
HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();

//Memasukan script yang kita download
InputStream inStrm = httpCon.getInputStream();
System.out.println("\nContent at " + url);
int ch;

//Mencetak seluruh script
while (((ch = inStrm.read()) != -1))
System.out.print((char) ch);
inStrm.close();
}
}

Tidak ada komentar: