If you use ADSL to access the Internet, you can create a free website at home, but the speed is not flattering.
In fact, it is to get the Internet IP address and then update the free Domain Name Information of mycool.net. In this way, when your ADSL Network is disconnected, the new IP address can be promptly updated to your free Domain Name System.
You need to apply for a free Domain Name On www.mycool.net, modify the user name and password in the code, and then run OK.
Import java. Io. bufferedreader;
Import java. Io. ioexception;
Import java. Io. inputstreamreader;
Import java. Io. outputstreamwriter;
Import java.net. malformedurlexception;
Import java.net. url;
Import java.net. urlconnection;
Import java. Text. messageformat;
Public final class Main ...{
Private Static string oldip = "";
Public static void main (string [] ARGs )...{
While (true )...{
String IP = getwanip ();
If (! Oldip. Equals (IP ))...{
Updatedomaininfo ("yourname", "oldpass", "newpass", "yourmail.domain.com", ip );
Oldip = IP;
}
Try ...{
Thread. Sleep (1000*60 );
} Catch (interruptedexception e )...{
E. printstacktrace ();
}
}
}
Private Static string getwanip ()...{
Bufferedreader in = NULL;
Try ...{
URL url = new URL ("http://vip.cn99.com/ret.php ");
In = new bufferedreader (New inputstreamreader (URL. openstream ()));
String STR = in. Readline ();
Return STR;
} Catch (malformedurlexception e )...{
} Catch (ioexception e )...{
} Finally ...{
If (in! = NULL)
Try ...{
In. Close ();
} Catch (ioexception e )...{}
}
Return NULL;
}
Private Static void updatedomaininfo (string user, string pass, string newpass, string email, string IP )...{
Try ...{
String data = "Action = modifybio & username = {0} & Password = {1} & Email = {2} & newpassword = {3} & url = http % 3A % 2f % 2f {4} & dirtype = No & submit = % C8 % B7 % B6 % A8 % D0 % de % B8 % c4 ";
Data = messageformat. Format (data, new string []... {user, pass, email, newpass, IP });
URL url = new URL ("http://mycool.net/cgi-bin/modi.cgi ");
Urlconnection conn = URL. openconnection ();
Conn. setdooutput (true );
Outputstreamwriter wR = new outputstreamwriter (conn. getoutputstream ());
Wr. Write (data );
Wr. Flush ();
Bufferedreader RD = new bufferedreader (New inputstreamreader (conn. getinputstream ()));
String line;
While (line = RD. Readline ())! = NULL )...{
}
Wr. Close ();
Rd. Close ();
System. Out. println ("Update domain to:" + IP );
} Catch (exception e )...{
E. printstacktrace ();
}
}
}