Home java строка не найдена

строка не найдена

Author

Date

Category

The fact is that in my application, depending on the battery, it is necessary to cause different methods. Actually, the question arose: how can I use the Java code to know the battery of the OS?


Answer 1, Authority 100%

Here is a piece of code from the working application:

string osname = system.getproperty ("os.name"). TolowerCase ();
String Osarch = System.GetProperty ("Os.arch"). TolowerCase ();
String SWTFILENAME =.
  Osname.Contains ("Win")? "Win":
  Osname.Contains ("Mac")? "MacOSX":
// osname.contains ("Linux") || Osname.Contains ("nix")? "Linux_GTK":
// Linux Version Is To Come Yet
  NULL;
if (SWTFILENAME == NULL)
 Throw New RuntimeException ("Unknown OS Name:" + Osname);
SWTFILENAME + = osarch.contains ("64")? "64": "32";
SWTVERSion = SWTFILENAME;
SWTFILENAME = "SWT_" + SWTFILENAME + ".JAR";

Answer 2, Authority 100%

version of the operating system, can be obtained via System Properties List :

string version = system.getProperty ("os.arch");

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions