We can get the System UUID by below code public class DeviceInfo { Process SerNumProcess = Runtime.getRuntime().exec(command); String line = ""; StringBuffer output = new StringBuffer(); BufferedReader sNumReader = new BufferedReader(new InputStreamReader(SerNumProcess.getInputStream())); String line = ""; while ((line = sNumReader.readLine()) != null) { String uuid=output.toString().substring(output.indexOf("UUID: "), output.length()).replace("UUID: ", ""); SerNumProcess.waitFor(); sNumReader.close(); System.out.println(uuid);
//Get Windows Machine UUID
public static String getWindowsDeviceUUID()
{
try{
String command = "wmic csproduct get UUID";
StringBuffer output = new StringBuffer();
BufferedReader sNumReader = new BufferedReader(new InputStreamReader(SerNumProcess.getInputStream()));
while ((line = sNumReader.readLine()) != null) {
output.append(line + "\n");
}
String uuid=output.toString().substring(output.indexOf("\n"), output.length()).trim();;
System.out.println(uuid);
return uuid;
}catch(Exception ex)
{
System.out.println("OutPut Error "+ex.getMessage());
}
return null;
}
//Get Mac Machine UUID
public static String getMacUUID()
{
try{
String command = "system_profiler SPHardwareDataType | awk '/UUID/ { print $3; }'";
Process SerNumProcess = Runtime.getRuntime().exec(command);
output.append(line + "\n");
}
return uuid;
}catch(Exception ex)
{
}
return null;
}
}
What is a Collection ?
How to split a string in Java
How to create Arraylist from Array in Java
How to Sort ArrayList of Object Type in Java?
How to Fetch System UUID with Java Program?
What is Java Collections Framework?
How to join Multiple String Objects in Java 8
How to convert ArrayList to Array in Java
How to Convert a Map to a List in Java Example
Java Thread - How to create Threads in Java?
What is difference between HashMap and HashSet in Java
What is Difference Between "==" and "equals" method in Java