Ip地址:a.b.c.d
專注于為中小企業(yè)提供網(wǎng)站設(shè)計、成都網(wǎng)站設(shè)計服務(wù),電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)于洪免費做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了近1000家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實現(xiàn)規(guī)模擴充和轉(zhuǎn)變。
比較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)?{
//?自己調(diào)用吧
}
}
網(wǎng)頁地址在代碼中的java代碼寫法如下:
packagecom.test;
importjava.lang.reflect.Method;
//實現(xiàn)打開瀏覽器并跳到指定網(wǎng)址的類
publicclassBareBonesBrowserLaunch{
publicstaticvoidopenURL(Stringurl){
try{
browse(url);
}catch(Exceptione){
}
}
privatestaticvoidbrowse(Stringurl)throwsException{
//獲取操作系統(tǒng)的名字
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++)
//執(zhí)行代碼,在brower有值后跳出,
//這里是如果進程創(chuàng)建成功了,==0是表示正常結(jié)束。
if(Runtime.getRuntime().exec(newString[]{"which",browsers[count]}).waitFor()==0)
browser=browsers[count];
if(browser==null)
thrownewException("Couldnotfindwebbrowser");
else
//這個值在上面已經(jīng)成功的得到了一個進程。
Runtime.getRuntime().exec(newString[]{browser,url});
}
}
}
//主方法測試類
publicstaticvoidmain(String[]args){
Stringurl="";
BareBonesBrowserLaunch.openURL(url);
}