I did like to show a motherboard serial number in text field (GUI panel). I created a text field and action button. I wrote this code in action button. What mistake did i make in this code?
try {
Process p = Runtime.getRuntime().exec("wmic baseboard get serialnumber");
BufferedReader inn = new BufferedReader(new InputStreamReader(p.getInputStream()));
while (true) {
String line = inn.readLine();
if (line == null) {
break;
}
motherboard.setText(line);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, "Sorry could not found motherboard serial!");
}
try
{
String result = null;
Process p = Runtime.getRuntime().exec("wmic baseboard get serialnumber");
BufferedReader input
= new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = input.readLine()) != null)
{
result += line;
}
if (result.equalsIgnoreCase(" ")) {
System.out.println("Result is empty");
} else
{
motherboard.setText(result);
}
input.close();
} catch (IOException ex)
{
Exceptions.printStackTrace(ex);
}