edu.stanford.hci.r3.util
Class SystemUtils

java.lang.Object
  extended by edu.stanford.hci.r3.util.SystemUtils

public class SystemUtils
extends java.lang.Object

Environment Variables, OS specific tasks, etc.

This software is distributed under the BSD License.


Field Summary
static java.lang.String LIBRARY_PATH_KEY
          Where to look for DLLs.
static java.lang.String LINE_SEPARATOR
          System character(s) for separating lines.
static java.lang.String PATH_SEPARATOR
          Different for UNIX/WINDOWS/MAC
 
Constructor Summary
SystemUtils()
           
 
Method Summary
static void addToLibraryPath(java.net.URL url)
          This doesn't work.
static double getFreeMemoryInMB()
           
static java.io.File getWorkingDirectory()
           
static boolean operatingSystemIsMacOSX()
          http://developer.apple.com/technotes/tn2002/tn2110.html
static boolean operatingSystemIsWindowsVariant()
           
static void setWorkingDirectory(java.io.File file)
          Deprecated.  
static void tic()
          Save the current time, for simple profiling.
static void toc()
          Prints out the difference between now and the last time we tic'ed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LIBRARY_PATH_KEY

public static final java.lang.String LIBRARY_PATH_KEY
Where to look for DLLs. Unfortunately, you cannot change this at runtime and expect the classloaders to find the dlls correctly.

See Also:
Constant Field Values

LINE_SEPARATOR

public static final java.lang.String LINE_SEPARATOR
System character(s) for separating lines. Different for Unix/DOS/Mac.


PATH_SEPARATOR

public static final java.lang.String PATH_SEPARATOR
Different for UNIX/WINDOWS/MAC

Constructor Detail

SystemUtils

public SystemUtils()
Method Detail

addToLibraryPath

public static void addToLibraryPath(java.net.URL url)
This doesn't work. =\ TODO: See: http://www.velocityreviews.com/forums/t143553-dll-in-jar.html for a possible solution to load dlls from the jar file. Alternate idea: http://forum.java.sun.com/thread.jspa?threadID=563861&messageID=3123713

Parameters:
url -

getFreeMemoryInMB

public static double getFreeMemoryInMB()
Returns:
the number of megabytes of free memory

getWorkingDirectory

public static java.io.File getWorkingDirectory()
Returns:
where new File(".").getAbsolutePath() points...

operatingSystemIsMacOSX

public static boolean operatingSystemIsMacOSX()
http://developer.apple.com/technotes/tn2002/tn2110.html

Returns:
true if the jvm is running on mac os x

operatingSystemIsWindowsVariant

public static boolean operatingSystemIsWindowsVariant()
Returns:
if the jvm is running on windows 9x/NT/2000/XP/Vista

setWorkingDirectory

public static void setWorkingDirectory(java.io.File file)
Deprecated. 

Sets the user.dir property, so that you can make code dealing with files easier to type/read. WARNING: Java seems to have a usability bug in this manner.... Do not use this method for now. SystemUtils.setWorkingDirectory(new File("data/Flickr/")); // argh! Setting the Working Directory doesn't work for files in this manner. // Quite Stupid, in fact. System.out.println(new File("Twistr1.xml").exists()); // returns false System.out.println(new File("Twistr1.xml").getAbsoluteFile().exists()); // returns true This is a KNOWN Java bug: http://bugs.sun.com/bugdatabase/view_bug.do;:YfiG?bug_id=4117557 Phooey. That means you have to call getAbsoluteFile() at every point in which you read a file stream. I will have to instrument SystemUtils & FileUtils to handle this.

Parameters:
file -

tic

public static void tic()
Save the current time, for simple profiling.


toc

public static void toc()
Prints out the difference between now and the last time we tic'ed.


Copyright 2006 Stanford University