Ip地址:a.b.c.d
专注于为中小企业提供网站设计、成都网站设计服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业于洪免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了近1000家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
比较Ip地址的大小就是
先比较两个IP的a部分,如果谁的大,那这个Ip就是叫大的Ip;
如果相等,就比较b部分;
向下走直到d部分。 public boolean compare(String startIp,String endIp){
String startips[]=startIp.split("\\.");
String endIps[]=endIp.split("\\.");
for(int i=0;istartips.length;i++){
if(Integer.parseInt(endIps[i])Integer.parseInt(startips[i])){
flag=true;
break;
}else{
if(Integer.parseInt(endIps[i])==Integer.parseInt(startips[i])){
continue;
}else{
break;
}
}
}
public class Address {
private String country;
private String province;
private String city;
private String county;;
private String street;
private String houseNum;
private String company;
private String postCode;
public Address(String country, String province, String city, String county, String street, String houseNum,
String company, String postCode) {
this.country = country;
this.province = province;
this.city = city;
this.county = county;
this.street = street;
this.houseNum = houseNum;
this.company = company;
this.postCode = postCode;
}
public void print() {
if ("中华人民共和国".equals(country))
System.out.println("邮寄地址 :" + country + "--" + province + "--" + city + "--" + county + "--" + street + "--"
+ houseNum + "--" + company + "--\n邮政编码:" + postCode);
else
System.out.println("Send to :" + houseNum + "--" + company + "--" + street + "--" + county + "--" + city
+ "--" + province + "--" + country + "--\nPost Code:" + postCode);
}
/**
*
* @param isInternational True is stand for International email
* @return The string of address
*/
public String print(Boolean isInternational) {
String address = "";
if (!isInternational)
address = country + "--" + province + "--" + city + "--" + county + "--" + street + "--" + houseNum + "--"
+ company + "--\n邮政编码:" + postCode;
else
address = houseNum + "--" + company + "--" + street + "--" + county + "--" + city + "--" + province + "--"
+ country + "--\nPost Code:" + postCode;
return address;
}
public static void main(String[] args) {
// 自己调用吧
}
}
网页地址在代码中的java代码写法如下:
packagecom.test;
importjava.lang.reflect.Method;
//实现打开浏览器并跳到指定网址的类
publicclassBareBonesBrowserLaunch{
publicstaticvoidopenURL(Stringurl){
try{
browse(url);
}catch(Exceptione){
}
}
privatestaticvoidbrowse(Stringurl)throwsException{
//获取操作系统的名字
StringosName=System.getProperty("os.name","");
if(osName.startsWith("MacOS")){
//苹果的打开方式
ClassfileMgr=Class.forName("com.apple.eio.FileManager");
MethodopenURL=fileMgr.getDeclaredMethod("openURL",newClass[]{String.class});
openURL.invoke(null,newObject[]{url});
}elseif(osName.startsWith("Windows")){
//windows的打开方式。
Runtime.getRuntime().exec("rundll32url.dll,FileProtocolHandler"+url);
}else{
//UnixorLinux的打开方式
String[]browsers={"firefox","opera","konqueror","epiphany","mozilla","netscape"};
Stringbrowser=null;
for(intcount=0;countbrowsers.lengthbrowser==null;count++)
//执行代码,在brower有值后跳出,
//这里是如果进程创建成功了,==0是表示正常结束。
if(Runtime.getRuntime().exec(newString[]{"which",browsers[count]}).waitFor()==0)
browser=browsers[count];
if(browser==null)
thrownewException("Couldnotfindwebbrowser");
else
//这个值在上面已经成功的得到了一个进程。
Runtime.getRuntime().exec(newString[]{browser,url});
}
}
}
//主方法测试类
publicstaticvoidmain(String[]args){
Stringurl="";
BareBonesBrowserLaunch.openURL(url);
}