Web开发可以理解为做网站
C/S的开发是服务器,客户端模式,这种模式下用户必须要安装客户端软件才能够使用系统的功能,而一旦有更新,用户必须重新下载客户端。
Web开发的B/S,浏览器/服务器模式则无需客户端软件,只要客户端安装Web浏览器就能够使用系统功能,而系统的更新也只需要管理员替换服务器文件就可以实现,无需用户去下载客户端。import javaioBufferedReader;
import javaioIOException;
import javaioInputStreamReader;
import javanetInetAddress;
import javanetNetworkInterface;
/
与系统相关的一些常用工具方法
@author lvbogun
@version 100
/
public class SystemTool {
/
获取当前 *** 作系统名称 return *** 作系统名称 例如:windows xp,linux 等
/
public static String getOSName() {
return SystemgetProperty("osname")toLowerCase();
}
/
获取unix网卡的mac地址 非windows的系统默认调用本方法获取
如果有特殊系统请继续扩充新的取mac地址方法
@return mac地址
/
public static String getUnixMACAddress() {
String mac = null;
BufferedReader bufferedReader = null;
Process process = null;
try {
// linux下的命令,一般取eth0作为本地主网卡
process = RuntimegetRuntime()exec("ifconfig eth0");
// 显示信息中包含有mac地址信息
bufferedReader = new BufferedReader(new InputStreamReader(
processgetInputStream()));
String line = null;
int index = -1;
while ((line = bufferedReaderreadLine()) != null) {
// 寻找标示字符串[hwaddr]
index = linetoLowerCase()indexOf("hwaddr");
if (index >= 0) {// 找到了
// 取出mac地址并去除2边空格
mac = linesubstring(index + "hwaddr"length() + 1)trim();
break;
}
}
} catch (IOException e) {
eprintStackTrace();
} finally {
try {
if (bufferedReader != null) {
bufferedReaderclose();
}
} catch (IOException e1) {
e1printStackTrace();
}
bufferedReader = null;
process = null;
}
return mac;
}
/
获取widnows网卡的mac地址
@return mac地址
/
public static String getWindowsMACAddress() {
String mac = null;
BufferedReader bufferedReader = null;
Process process = null;
try {
// windows下的命令,显示信息中包含有mac地址信息
process = RuntimegetRuntime()exec("ipconfig /all");
bufferedReader = new BufferedReader(new InputStreamReader(
processgetInputStream()));
String line = null;
int index = -1;
while ((line = bufferedReaderreadLine()) != null) {
Systemoutprintln(line);
// 寻找标示字符串[physical
index = linetoLowerCase()indexOf("physical address");
if (index >= 0) {// 找到了
index = lineindexOf(":");// 寻找":"的位置
if (index >= 0) {
Systemoutprintln(mac);
// 取出mac地址并去除2边空格
mac = linesubstring(index + 1)trim();
}
break;
}
}
} catch (IOException e) {
eprintStackTrace();
} finally {
try {
if (bufferedReader != null) {
bufferedReaderclose();
}
} catch (IOException e1) {
e1printStackTrace();
}
bufferedReader = null;
process = null;
}
return mac;
}
/
windows 7 专用 获取MAC地址
@return
@throws Exception
/
public static String getMACAddress() throws Exception {
// 获取本地IP对象
InetAddress ia = InetAddressgetLocalHost();
// 获得网络接口对象(即网卡),并得到mac地址,mac地址存在于一个byte数组中。
byte[] mac = NetworkInterfacegetByInetAddress(ia)getHardwareAddress();
// 下面代码是把mac地址拼装成String
StringBuffer sb = new StringBuffer();
for (int i = 0; i < maclength; i++) {
if (i != 0) {
sbappend("-");
}
// mac[i] & 0xFF 是为了把byte转化为正整数
String s = IntegertoHexString(mac[i] & 0xFF);
sbappend(slength() == 1 0 + s : s);
}
// 把字符串所有小写字母改为大写成为正规的mac地址并返回
return sbtoString()toUpperCase();
}
}
写一个全局拦截的servlet,只要有请求的时候就调用这个类里面的获取mac地址的方法
String os = getOSName();
Systemoutprintln(os);
if (osequals("windows 7")) {
String mac = getMACAddress();
Systemoutprintln(mac);
} else if (osstartsWith("windows")) {
// 本地是windows
String mac = getWindowsMACAddress();
Systemoutprintln(mac);
} else {
// 本地是非windows系统 一般就是unix
String mac = getUnixMACAddress();
Systemoutprintln(mac);
}
记得判断一下是什么系统手机的移动数据流量没有打开。
手机的移动数据流量没有打开,连接的只是内网,不能连接外网的。所以下载不了。
手机上网无法下载的原因有多种,其中主要原因包括:无线信号较弱。3G信号较弱。手机参数设置错误。WAP或者WEB服务器故障,建议可以重新设置一下手机参数。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)