We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Is there a way to read a laptop's battery in processing? Or eventually to see if energy saving mode is active?
I think you cannot do it directly, but you could call platform-specific commands with exec(). For example on OSX this would give you some information that you could parse:
import java.io.InputStreamReader; String commandToRun = "pmset -g batt"; try { Process proc = (Runtime.getRuntime()).exec(commandToRun); BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream())); String response=null; while ((response = stdInput.readLine()) != null) { System.out.println(response); } } catch(Exception e) { println(e); }
sadly I don't have any apple laptop, is there something that works for windows or linux? Or what should I look for anyway?
Answers
I think you cannot do it directly, but you could call platform-specific commands with exec(). For example on OSX this would give you some information that you could parse:
sadly I don't have any apple laptop, is there something that works for windows or linux? Or what should I look for anyway?