JAVA合并多个byte[]为一个byte[]
private static byte[] byteMergerAll(byte[]... args) {
int length_byte = 0;
for (byte[] b : args) {
length_byte += b.length;
}
byte[] all_byte = new byte[length_byte];
int countLength = 0;
for (byte[] b : args) {
System.arraycopy(b, 0, all_byte, countLength, b.length);
countLength += b.length;
}
return all_byte;
}
参考链接:
Android 获取MAC地址
/**
* 获取无线网络Mac地址
*
* @return
*/
private static String getWifiMac() {
return readFile("/sys/class/net/wlan0/address").toUpperCase();
}
/**
* 获取有线网络Mac地址
*
* @return
*/
private static String getLocalMac() {
return readFile("/sys/class/net/eth0/address").toUpperCase();
}
/**
* 读取文件内容
*
* @param filePath
* @return
*/
private static String readFile(String filePath) {
StringBuilder sb = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
String line;
while ((line = reader.readLine()) != null) {
if (sb.length() > 0) {
sb.append("\n");
}
sb.append(line);
}
} catch (IOException e) {
e.printStackTrace();
}
return sb.toString();
}
PS:笔者是在定制安卓设备上面开发,用该方式获取Mac地址没问题。
PS2:手机上因为权限问题很可能获取不了Mac地址,请自行测试。
PS3:不过一般来说,手机上也不用获取有线网络的Mac地址才对。
参考链接:
音视频通信相关资料
在线编程语言速学网
WebRTC相关资料
SOCKET通信
CRC算法相关资料
树莓派相关网站
安装vim编辑器 sudo apt-get install vim
编辑文件 /etc/dhcpcd.conf,在文件末尾增加 interface wlan0 inform 192.168.2.188
sudo apt-get install android-tools-adb
sudo systemctl enable ssh sudo systemctl start ssh
Android使用ADB命令查看设备分辨率和屏幕密度(DPI)
查看设备分辨率:
adb shell wm size
查看屏幕密度(DPI):
adb shell wm density
参考链接: