so I am looking for the equivelent of you know
wget or fetch
I tried this code, except all it does is display , Hello World, Hello Android
Anyone got any idea how to download a web page?
wget or fetch
I tried this code, except all it does is display , Hello World, Hello Android
Anyone got any idea how to download a web page?
Code:
package com.dslice;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import org.apache.http.util.ByteArrayBuffer;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.widget.Toast;
public class HelloAndroid extends Activity {
private String html = "";
private Handler mHandler;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mHandler = new Handler();
checkUpdate.start();
}
private Thread checkUpdate = new Thread() {
public void run() {
try {
URL updateURL = new URL("http://iconic.4feets.com/update");
URLConnection conn = updateURL.openConnection();
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(50);
int current = 0;
while((current = bis.read()) != -1){
baf.append((byte)current);
}
/* Convert the Bytes read to a String. */
html = new String(baf.toByteArray());
mHandler.post(showUpdate);
} catch (Exception e) {
}
}
};
private Runnable showUpdate = new Runnable(){
public void run(){
Toast.makeText(HelloAndroid.this, "HTML Code: " + html, Toast.LENGTH_SHORT).show();
}
};
}