「Java指定ip」java指定概率抽奖

博主:adminadmin 2022-12-04 14:15:08 70

今天给各位分享Java指定ip的知识,其中也会对java指定概率抽奖进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

java 如何获取指定ip数据

String userIp = request.getRemoteAddr();

if (userIp.equals("目标ip")) {

//TODO 获取需要的数据

}else {

//TODO 不满足条件,做其他处理

}

java11debug设置ip

1、首先打开java11debug软件。

2、其次点击右上角的菜单。

3、最后点击地址,点击ip地址,进行设置即可。

JAVA中如何获取指定IP的MAC地址

public static String getMacAddressIP(String remotePcIP) {

String str = "";

String macAddress = "";

try {

Process pp = Runtime.getRuntime().exec("nbtstat -A " + remotePcIP);

InputStreamReader ir = new InputStreamReader(pp.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;

}

}

}

} catch (IOException ex) {

}

return macAddress;

}

用JAVA如何实现IP绑定

package src;

import java.io.*;

public class getMac {

public static void main(String[] args) {

try {

Process process = Runtime.getRuntime().exec("ipconfig /all");

InputStreamReader ir = new InputStreamReader(process

.getInputStream());

LineNumberReader input = new LineNumberReader(ir);

String line;

while ((line = input.readLine()) != null)

if (line.indexOf("Physical Address") 0) {

String MACAddr = line.substring(line.indexOf("-") - 2);

System.out.println("MAC address = [" + MACAddr + "]");

}

} catch (java.io.IOException e) {

System.err.println("IOException " + e.getMessage());

}

}

}

ipconfig是Windows下命令提示符支持的一个命令,可以查询到你的机器的ip等网络配置

Runtime.getRuntime().exec("ipconfig /all"); 就是执行该命令

if (line.indexOf("Physical Address") 0)表示如果在line中查找到Physical Address,就继续执行if中的语句,否则如果找不到,line.indexOf("Physical Address")的返回值=-1

请多少给点分,谢谢

java程序如何绑定服务器IP?

你把这个方法写进你的程序,程序开始后先获取IP,然后判断IP是否和你的一致,如果不一致直接return;即可.

/**

* 获取外网IP

* @param request

* @return

*/

public static String getIpAddr(HttpServletRequest request) {

String ipAddress = null;

// ipAddress = this.getRequest().getRemoteAddr();

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

if (ipAddress == null || ipAddress.length() == 0

|| "unknown".equalsIgnoreCase(ipAddress)) {

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

}

if (ipAddress == null || ipAddress.length() == 0

|| "unknown".equalsIgnoreCase(ipAddress)) {

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

}

if (ipAddress == null || ipAddress.length() == 0

|| "unknown".equalsIgnoreCase(ipAddress)) {

ipAddress = request.getRemoteAddr();

if (ipAddress.equals("127.0.0.1")) {

// 根据网卡取本机配置的IP

InetAddress inet = null;

try {

inet = InetAddress.getLocalHost();

} catch (UnknownHostException e) {

e.printStackTrace();

}

ipAddress = inet.getHostAddress();

}

}

// 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割

if (ipAddress != null ipAddress.length() 15) { // "***.***.***.***".length()

// = 15

if (ipAddress.indexOf(",") 0) {

ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));

}

}

return ipAddress;

}

————————————————

版权声明:本文为CSDN博主「秋9」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。

原文链接:

Java指定ip的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java指定概率抽奖、Java指定ip的信息别忘了在本站进行查找喔。

The End

发布于:2022-12-04,除非注明,否则均为首码项目网原创文章,转载请注明出处。