|
SoftNet-Consult Java Utility Library | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.softnetConsult.utils.sys.SystemTools
public final class SystemTools
Static system, memory and time management utility functions.
This product includes software developed by the
SoftNet-Consult Java Utility Library project and its contributors.
(http://java-tools.sourceforge.net)
Copyright (c) 2007-2008 SoftNet-Consult.
Copyright (c) 2007-2008 G. Paperin.
All rights reserved.
File: SystemTools.java
Library API version: "2.02"
Java compliance version: "1.5"
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following terms and conditions are met:
1. Redistributions of source code must retain the above
acknowledgement of the SoftNet-Consult Java Utility Library project, the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above acknowledgement of the
SoftNet-Consult Java Utility Library project, the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
3. All advertising materials mentioning features or use of this software or any derived
software must display the following acknowledgement:
This product includes software developed by the SoftNet-Consult Java Utility Library
project and its contributors.
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Constructor Summary | |
---|---|
private |
SystemTools()
Prevents instances of this class from being created as this class contains only static utility methods. |
Method Summary | |
---|---|
static java.lang.String |
formatTime(int millis,
int secs,
int mins,
int hours,
int days)
Formats a time interval to a nicely readable format without the need to involve a formatter. |
static java.lang.String |
formatTimePeriod(long startMillis,
long endMillis)
Formats the specified time period as specified in formatTime(int, int, int, int, int) ;
note that timePeriod(long, long) is used to process the time period and therefore the
same restrictions as in that method apply to this method. |
static ClassVersionInfo |
getClassVersionInfo(java.io.File classfile)
Gets the class version info of the specified Java class file. |
static ClassVersionInfo |
getClassVersionInfo(java.lang.String classfile)
Gets the class version info of the specified Java class file. |
static java.lang.String |
getMemInfoString()
Fetches the current memory information and formats the data in a human readable string. |
static void |
printMemInfoLine()
Prints a human readable line with the current memory information to std-out, equivalent to System.out.println(getMemInfoString()) . |
static void |
sleep(long millis)
Allows calling Thread.sleep without the nuisance of surrounding the call with
a try-catch block. |
static void |
sleep(long millis,
int nanos)
Allows calling Thread.sleep without the nuisance of surrounding the call with
a try-catch block. |
static int[] |
timePeriod(long startMillis,
long endMillis)
Determines how many days, hours, minutes, seconds and milliseconds the specified time period contains. |
static void |
wait(long millis,
int nanos,
java.lang.Object object)
Allows calling Object.wait without the nuisance of surrounding the call with
a try-catch block. |
static void |
wait(long millis,
java.lang.Object object)
Allows calling Object.wait without the nuisance of surrounding the call with
a try-catch block. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
private SystemTools()
Method Detail |
---|
public static java.lang.String getMemInfoString()
public static void printMemInfoLine()
System.out.println(getMemInfoString())
.
public static void sleep(long millis)
Thread.sleep
without the nuisance of surrounding the call with
a try-catch
block. A possible InterruptedException
is caught and ignored.
millis
- The length of time to sleep in milliseconds.public static void sleep(long millis, int nanos)
Thread.sleep
without the nuisance of surrounding the call with
a try-catch
block. A possible InterruptedException
is caught and ignored.
millis
- The length of time to sleep in milliseconds.nanos
- 0-999999 additional nanoseconds to sleep.public static void wait(long millis, java.lang.Object object)
Object.wait
without the nuisance of surrounding the call with
a try-catch
block. A possible InterruptedException
is caught and ignored.
millis
- The length of time to sleep in milliseconds.object
- The object for which to wait.public static void wait(long millis, int nanos, java.lang.Object object)
Object.wait
without the nuisance of surrounding the call with
a try-catch
block. A possible InterruptedException
is caught and ignored.
millis
- The length of time to sleep in milliseconds.nanos
- 0-999999 additional nanoseconds to sleep.object
- The object for which to wait.public static int[] timePeriod(long startMillis, long endMillis)
startMillis
and endMillis
may not be larger than 185542587187199999L
milliseconds, as an internal
overflow would occur otherwise. The limit of 185542587187199999L milliseconds
corrsponds to
( (Integer.MAX_VALUE + 1L) * 86400000L - 1L ) milliseconds
or
Integer.MAX_VALUE days, 23 hours, 59 minures and 59.999 seconds
or
2147483647 days, 23:59:59.999
.
startMillis
- The milliseconds marking the beginning of a time period.endMillis
- The milliseconds marking the end of a time period.
int
-array containg exactly 5 following elements:[4]
: number of whole days in the specified time period;[3]
: number of whole hours not covered by the whole days in the specified time period;[2]
: number of whole minutes not covered by the whole hours in the specified time period;[1]
: number of whole seconds not covered by the whole mins in the specified time period;[0]
: number of whole millisecs not covered by the whole secs in the specified time period;java.lang.IllegalArgumentException
- If the absolute value of the difference between startMillis
and endMillis
is larger than 185542587187199999L
.public static java.lang.String formatTime(int millis, int secs, int mins, int hours, int days)
millis
- Millisecondssecs
- Seconds.mins
- Minutes.hours
- Hours.days
- Days.
3 days, 17:08:53.006
.public static java.lang.String formatTimePeriod(long startMillis, long endMillis)
formatTime(int, int, int, int, int)
;
note that timePeriod(long, long)
is used to process the time period and therefore the
same restrictions as in that method apply to this method.
startMillis
- The milliseconds marking the beginning of a time period.endMillis
- The milliseconds marking the end of a time period.
3 days, 17:08:53.006
.timePeriod(long, long)
,
formatTime(int, int, int, int, int)
public static ClassVersionInfo getClassVersionInfo(java.io.File classfile) throws java.io.IOException
classfile
- A File
representing a physical Java class file.
ClassVersionInfo
-object containing information about the
major and the minor versions of the specified class file as well as the minimum
JVM version required to run that class file. If the specified file is not a valid
Java class file (according to the magic numer check) this method returns null
.
java.io.IOException
- If there was an error when reading the specified file.public static ClassVersionInfo getClassVersionInfo(java.lang.String classfile) throws java.io.IOException
classfile
- The full path of a physical Java class file.
ClassVersionInfo
-object containing information about the
major and the minor versions of the specified class file as well as the minimum
JVM version required to run that class file. If the specified file is not a valid
Java class file (according to the magic numer check) this method returns null
.
java.io.IOException
- If there was an error when reading the specified file.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |