真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

java收貨地址解析代碼 收貨地址代碼怎么寫(xiě)

求獲取客戶端mac地址java代碼,急需急需,麻煩了

通過(guò)ip獲取指定ip地址的mac地址,ip可以通過(guò)請(qǐng)求request獲取,

公司主營(yíng)業(yè)務(wù):成都網(wǎng)站建設(shè)、成都做網(wǎng)站、移動(dòng)網(wǎng)站開(kāi)發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競(jìng)爭(zhēng)能力。成都創(chuàng)新互聯(lián)公司是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開(kāi)放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對(duì)我們的高要求,感謝他們從不同領(lǐng)域給我們帶來(lái)的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶帶來(lái)驚喜。成都創(chuàng)新互聯(lián)公司推出埇橋區(qū)免費(fèi)做網(wǎng)站回饋大家。

request.getRemoteAddr();

(當(dāng)然獲取ip也不是在任何情況下都有效的)

通過(guò)了Apache,Squid等反向代理軟件就不能獲取到客戶端的真實(shí)IP地址。

您也許需要通過(guò)其他的方式獲取,(見(jiàn)附)

//獲取mac如下 (nbtstat -A IPAddress是對(duì)給定的IP地址解析其主機(jī)名。如果不能正常解析它的主機(jī)

//名的話,有可能是防火墻屏蔽了。也可能是在DNS中將NetBios 解析選項(xiàng)屏蔽了。)

public String getMACAddress(String ip){

String str = "";

String macAddress = "";

try {

Process p = Runtime.getRuntime().exec("nbtstat -A " + ip);

InputStreamReader ir = new InputStreamReader(p.getInputStream());

LineNumberReader input = new LineNumberReader(ir);

for (int i = 1; i 100; i++) {

str = input.readLine();

if (str != null) {

if (str.indexOf("MAC Address") 1) {

macAddress = str.substring(str.indexOf("MAC Address") + 14, str.length());

break;

}

if (str.indexOf("MAC Address") 1) {

macAddress = str.substring(str.indexOf("MAC 地址") + 14, str.length());

break;

}

//以上有個(gè)判斷,不同系統(tǒng)cmd命令執(zhí)行的返回結(jié)果展示方式不一樣,我測(cè)試的win7是MAC 地址

//所以又第二個(gè)if判斷 你可先在你機(jī)器上cmd測(cè)試下nbtstat -A 命令 當(dāng)然得有一個(gè)你可以ping通的

//網(wǎng)絡(luò)ip地址,然后根據(jù)你得到的結(jié)果中mac地址顯示方式來(lái)確定這個(gè)循環(huán)取值

}

}

} catch (IOException e) {

e.printStackTrace(System.out);

}

return macAddress;

}

附:

通過(guò)代理了的客戶端ip地址獲取方式

于是可得出獲得客戶端真實(shí)IP地址的方法一:

public String getRemortIP(HttpServletRequest request) {

if (request.getHeader("x-forwarded-for") == null) {

return request.getRemoteAddr();

}

return request.getHeader("x-forwarded-for");

}

獲得客戶端真實(shí)IP地址的方法二:

public String getIpAddr(HttpServletRequest request) {

String ip = request.getHeader("x-forwarded-for");

if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {

ip = request.getHeader("Proxy-Client-IP");

}

if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {

ip = request.getHeader("WL-Proxy-Client-IP");

}

if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {

ip = request.getRemoteAddr();

}

return ip;

}

可是,如果通過(guò)了多級(jí)反向代理的話,X-Forwarded-For的值并不止一個(gè),而是一串IP值,究竟哪個(gè)才是真正的用戶端的真實(shí)IP呢?

答案是取X-Forwarded-For中第一個(gè)非unknown的有效IP字符串。如:

X-Forwarded-For:192.168.1.110, 192.168.1.120, 192.168.1.130, 192.168.1.100

用戶真實(shí)IP為: 192.168.1.110

java 解析 eml的源代碼

//?從EML文件得到MimeMessage對(duì)象

MimeMessage?message?=?new?MimeMessage(session,?new?FileInputStream(emlFile));

public?static?String?getMailSubject(Message?message)?throws?Exception?{

return?MimeUtility.decodeText(message.getSubject());

}

public?static?String?getMailSender(Message?message)?throws?Exception?{

String?emailSender?=?null;

Address[]?addresses?=?message.getFrom();

if?(addresses?==?null?||?addresses.length??1)?{

throw?new?IllegalArgumentException("該郵件沒(méi)有發(fā)件人");

}

//?獲得發(fā)件人

InternetAddress?address?=?(InternetAddress)?addresses[0];

String?senderName?=?address.getPersonal();

if?(senderName?!=?null)?{

senderName?=?MimeUtility.decodeText(senderName);

emailSender?=?senderName?+?""?+?address.getAddress()?+?"";

}?else?{

senderName?=?address.getAddress();

}

return?emailSender;

}

public?static?String?getMailRecipients(Message?message,?Message.RecipientType?recipientType)?throws?Exception?{

StringBuilder?builder?=?new?StringBuilder();

Address[]?addresses?=?null;

if?(recipientType?==?null)?{

addresses?=?message.getAllRecipients();

}?else?{

addresses?=?message.getRecipients(recipientType);

}

if?(addresses?==?null?||?addresses.length??1)?{

throw?new?IllegalArgumentException("該郵件沒(méi)有收件人");

}

for?(Address?address?:?addresses)?{

InternetAddress?iAddress?=?(InternetAddress)?address;

builder.append(iAddress.toUnicodeString()).append(",?");

}

return?builder.deleteCharAt(builder.length()?-?1).toString();

}

public?static?String?getMailSendDate(Message?message,?String?pattern)?throws?Exception?{

String?sendDateString?=?null;

if?(pattern?==?null?||?"".equals(pattern.trim()))?{

pattern?=?"yyyy年MM月dd日?E?HH:mm";

}

Date?sendDate?=?message.getSentDate();

sendDateString?=?new?SimpleDateFormat(pattern).format(sendDate);

return?sendDateString;

}

public?static?boolean?containsAttachment(Part?part)?throws?Exception?{

boolean?flag?=?false;

if?(part?!=?null)?{

if?(part.isMimeType("multipart/*"))?{

MimeMultipart?mp?=?(MimeMultipart)?part.getContent();

for?(int?i?=?0;?i??mp.getCount();?i++)?{

BodyPart?bodyPart?=?mp.getBodyPart(i);

String?disposition?=?bodyPart.getDisposition();

if?(disposition?!=?null??(Part.ATTACHMENT.equalsIgnoreCase(disposition)

||?Part.INLINE.equalsIgnoreCase(disposition)))?{

flag?=?true;

}?else?if?(bodyPart.isMimeType("multipart/*"))?{

flag?=?containsAttachment(bodyPart);

}?else?{

String?contentType?=?bodyPart.getContentType();

if?(contentType.indexOf("application")?!=?-1)?{

flag?=?true;

}

if?(contentType.indexOf("name")?!=?-1)?{

flag?=?true;

}

}

if?(flag)

break;

}

}?else?if?(part.isMimeType("message/rfc822"))?{

flag?=?containsAttachment((Part)?part.getContent());

}

}

return?flag;

}

public?static?boolean?isSeen(Message?message)?throws?Exception?{

if?(message?==?null)?{

throw?new?MessagingException("Message?is?empty");

}

return?message.getFlags().contains(Flags.Flag.SEEN);

}

public?static?boolean?isReplaySign(Message?message)?throws?Exception?{

if?(message?==?null)?{

throw?new?MessagingException("Message?is?empty");

}

boolean?replaySign?=?false;

String[]?headers?=?message.getHeader("Disposition-Notification-To");

if?(headers?!=?null??headers.length??0)?{

replaySign?=?true;

}

return?replaySign;

}

public?static?String?getMailPriority(Message?message)?throws?Exception?{

if?(message?==?null)?{

throw?new?MessagingException("Message?is?empty");

}

String?priority?=?"普通";

String[]?headers?=?message.getHeader("X-Priority");

if?(headers?!=?null??headers.length??0)?{

String?mailPriority?=?headers[0];

if?(mailPriority.indexOf("1")?!=?-1?||?mailPriority.indexOf("High")?!=?-1)?{

priority?=?"緊急";

}?else?if?(mailPriority.indexOf("5")?!=?-1?||?mailPriority.indexOf("Low")?!=?-1)?{

priority?=?"低";

}?else?{

priority?=?"普通";?//?3或者Normal;

}

}

return?priority;

}

public?static?void?getMailTextContent(Part?part,?StringBuilder?content)?throws?Exception?{

if?(part?==?null)?{

throw?new?MessagingException("Message?content?is?empty");

}

boolean?containsTextInAttachment?=?part.getContentType().indexOf("name")??0;

if?(part.isMimeType("text/*")??containsTextInAttachment)?{

content.append(part.getContent().toString());

}?else?if?(part.isMimeType("message/rfc822"))?{

getMailTextContent((Part)?part.getContent(),?content);

}?else?if?(part.isMimeType("multipart/*"))?{

Multipart?mp?=?(Multipart)?part.getContent();

for?(int?i?=?0;?i??mp.getCount();?i++)?{

BodyPart?bodyPart?=?mp.getBodyPart(i);

getMailTextContent(bodyPart,?content);

}

}?else?if?(part.isMimeType("image/*"))?{

//?TODO?part.getInputStream()獲得輸入流然后輸出到指定的目錄

}?else?{

//?TODO?其它類(lèi)型的contentType,?未做處理,?直接輸出

content.append(part.getContent().toString());

}

}

public?static?void?saveAttachment(Part?part,?String?destDir)?throws?Exception?{

if?(part?==?null)?{

throw?new?MessagingException("part?is?empty");

}

//?復(fù)雜的郵件包含多個(gè)郵件體

if?(part.isMimeType("multipart/*"))?{

Multipart?mp?=?(Multipart)?part.getContent();

//?遍歷每一個(gè)郵件體

for?(int?i?=?0;?i??mp.getCount();?i++)?{

BodyPart?bodyPart?=?mp.getBodyPart(i);

//?bodyPart也可能有多個(gè)郵件體組成

String?disposition?=?bodyPart.getDisposition();

if?(disposition?==?null??(Part.ATTACHMENT.equalsIgnoreCase(disposition)

||?Part.INLINE.equalsIgnoreCase(disposition)))?{

InputStream?in?=?bodyPart.getInputStream();

saveFile(in,?destDir,?decodeText(bodyPart.getFileName()));

}?else?if?(bodyPart.isMimeType("multipart/*"))?{

saveAttachment(bodyPart,?destDir);

}?else?{

String?contentType?=?bodyPart.getContentType();

if?(contentType.indexOf("name")?!=?-1?||?contentType.indexOf("application")?!=?-1)?{

saveFile(bodyPart.getInputStream(),?destDir,?decodeText(bodyPart.getFileName()));

}

}

}

}?else?if?(part.isMimeType("message/rfc822"))?{

saveAttachment((Part)?part.getContent(),?destDir);

}

}

public?static?void?saveFile(InputStream?in,?String?destDir,?String?fileName)?throws?Exception?{

FileOutputStream?out?=?new?FileOutputStream(new?File(destDir?+?fileName));

byte[]?buffer?=?new?byte[1024];

int?length?=?0;

while?((length?=?in.read(buffer))?!=?-1)?{

out.write(buffer,?0,?length);

}

out.close();

in.close();

}

public?static?String?decodeText(String?encodedText)?throws?Exception?{

if?(encodedText?==?null?||?"".equals(encodedText.trim()))?{

return?"";

}?else?{

return?MimeUtility.decodeText(encodedText);

}

}

java 代碼解析

設(shè)u和v是類(lèi)A的兩個(gè)對(duì)象——u和v是類(lèi)A的兩個(gè)實(shí)例?

u==v

的意思是判斷u和v是否是同一個(gè)實(shí)例。

如果返回true,表示u和v是A的同一個(gè)實(shí)例。

如果返回false,表示u和v是A的兩個(gè)不同實(shí)例。

電商網(wǎng)站 java 如何校驗(yàn)收貨地址

這個(gè)我猜的,

一般省 - 市 - 縣/區(qū) 這些三級(jí)聯(lián)動(dòng)

然后就是具體的地址。

這些地址有可能是它們買(mǎi)的,也有可能是自己積累過(guò)來(lái)的。

例如用戶填寫(xiě)了一個(gè)地址,只要這個(gè)訂單成功送達(dá),這個(gè)地址就進(jìn)入有效庫(kù)。京東用戶那么多,數(shù)據(jù)積累量肯定沒(méi)問(wèn)題。

java抓包解析后ip地址輸出到一個(gè)數(shù)組元素a[12]中,如何將相同ip地址數(shù)目統(tǒng)計(jì)并輸出?求源碼

private String s = "";//這個(gè)就是要求的a[12]

private ListString getTestAddress(){//這個(gè)測(cè)試方法改成你解析IP的方法

ListString address = new ArrayListString();

address.add("192.168.1.60");

address.add("192.168.1.61");

address.add("192.168.2.60");

address.add("192.168.1.60");

address.add("192.168.1.63");

address.add("192.168.1.64");

address.add("192.168.1.65");

address.add("192.168.2.60");

address.add("192.168.1.60");

return address;

}

private MapString, Integer getAddressNumber(){//把每一個(gè)ip跟其數(shù)量放入映射中,如果數(shù)量為0,表示無(wú)重復(fù)IP

MapString, Integer map = new HashMapString, Integer();

ListString address = getTestAddress();

for(int i=0; iaddress.size(); i++){

String ip1 = address.get(i);

s = s + ip1 + ",";//將IP組合成字符串,然后賦值給a[12]

int number = 0;

for(int j=address.size()-1; j i; j--){

String ip2 = address.get(j);

if(ip1.equals(ip2))

number += 1;

}

map.put(ip1, number);

}

return map;

}


網(wǎng)站名稱:java收貨地址解析代碼 收貨地址代碼怎么寫(xiě)
網(wǎng)站地址:http://weahome.cn/article/docdpji.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部