Or you could use this:
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URL;
import java.util.Scanner;
/**
* @since August 11, 2006, 10:52 AM
* @author Ian Schneider
*/
public class TestAuthenticator {
public static void main(String[] args) throws Exception {
String site = args[0];
final String name = args[1];
final String pass = args[2];
URL url = new URL(site);
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(name,pass.toCharArray());
}
});
System.out.println(new Scanner(url.openStream()).useDelimiter("\\z").next());
}
}
Ok thanks that part works but how do i make it grap the whole page? i get like the top portion and im assuming that the useDelimiter has something to do with that.
what i want to do exactly is save that file to my computer. Basicly copying the site that im connecting to or better yet leaving it in memory to be parsed. I want to grab some fields and print them to screen.
Thanks for the help