class Misc {

	public static String getFileSystemFreeSpace() {
		try {
			Method getFreeSpace = File.class.getMethod("getFreeSpace", (java.lang.Class[]) null);
			String dirName = System.getProperty("APPSERVER_ROOT_DIR");
			if (dirName==null) {
				dirName = System.getProperty("user.dir");
				if (dirName==null) {
					return null;
				}
			}
			File file = new File(dirName);
			long l = ((Long) getFreeSpace.invoke(file, (java.lang.Object[]) null)).longValue();
			return toFileSize(l);
		} catch ( NoSuchMethodException e ) {
			log.debug("Caught NoSuchMethodException, just not on JDK 1.6: "+e.getMessage());
			return null;
		} catch ( Exception e ) {
			log.debug("Caught Exception",e);
			return null;
		}
	}

}