本文整理汇总了Java中org.apache.commons.io.FileSystemUtils.freeSpaceKb方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystemUtils.freeSpaceKb方法的具体用法?Java FileSystemUtils.freeSpaceKb怎么用?Java FileSystemUtils.freeSpaceKb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.io.FileSystemUtils
的用法示例。
在下文中一共展示了FileSystemUtils.freeSpaceKb方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkDiskSpaceInTargetDirectory
import org.apache.commons.io.FileSystemUtils; //导入方法依赖的package包/类
/***
* Determines if the target directory for extraction has sufficient space to store the output of data extraction
* @param serverInfoMap
* @param targetDirectory
* @return True if sufficient space , false otherwise
* @throws IOException
*/
public static boolean checkDiskSpaceInTargetDirectory(Map<String, ServerInfo> serverInfoMap, String targetDirectory) throws IOException {
long totalDiskDirSize = getTotalSize(serverInfoMap);
long totalSpaceAvailable = FileSystemUtils.freeSpaceKb(targetDirectory);
GemFireXDDataExtractorImpl.logInfo("Total size of data to be extracted : " + (double)totalDiskDirSize/1024d + "MB");
GemFireXDDataExtractorImpl.logInfo("Disk space available in the output directory : " + (double)totalSpaceAvailable/1024d + "MB");
if (totalSpaceAvailable < totalDiskDirSize) {
if ("n".equalsIgnoreCase(getUserInput())) {
return false;
}
} else {
GemFireXDDataExtractorImpl.logInfo("Sufficient disk space to carry out data extraction");
}
return true;
}
示例2: getFreeDiskspace
import org.apache.commons.io.FileSystemUtils; //导入方法依赖的package包/类
public DiskUsage getFreeDiskspace() {
long freeSpace = -1L;
try {
freeSpace = FileSystemUtils.freeSpaceKb("/");
} catch (IOException e) {
models.utils.LogUtils.printLogError("Error in getFreeDiskspace() " + e.getLocalizedMessage());
//e.printStackTrace();
}
int gb = 1024*1024;
DiskUsage usage = new DiskUsage();
usage.freeSpaceGb = (double)freeSpace/ (double)gb;
if(VarUtils.IN_DETAIL_DEBUG){
models.utils.LogUtils.printLogNormal("Free Space:" + usage.freeSpaceGb + " GB");
}
currentDiskUsage = usage;
return usage;
}
示例3: getFreeDiskSpace
import org.apache.commons.io.FileSystemUtils; //导入方法依赖的package包/类
public Long getFreeDiskSpace() throws SecurityException, IOException,
SearchLibException {
try {
long l = ClientFactory.INSTANCE.properties.getMaxStorage();
if (l > 0) {
l -= ClientCatalog.getInstanceSize();
if (l < 0)
l = 0;
return l;
}
if (StartStopListener.OPENSEARCHSERVER_DATA_FILE.getClass()
.getDeclaredMethod("getFreeSpace") != null)
return StartStopListener.OPENSEARCHSERVER_DATA_FILE
.getFreeSpace();
} catch (NoSuchMethodException e) {
}
return FileSystemUtils
.freeSpaceKb(StartStopListener.OPENSEARCHSERVER_DATA_FILE
.getAbsolutePath()) * 1000;
}
示例4: getDiskSpace
import org.apache.commons.io.FileSystemUtils; //导入方法依赖的package包/类
private long getDiskSpace() {
try {
return FileSystemUtils.freeSpaceKb("/");
} catch (IOException e) {
LOG.error(e.toString(), e);
return -1L;
}
}
示例5: getDiskSpace
import org.apache.commons.io.FileSystemUtils; //导入方法依赖的package包/类
private long getDiskSpace() {
try {
return FileSystemUtils.freeSpaceKb(dataDir);
} catch (IOException e) {
LOG.error(e.toString(), e);
return -1L;
}
}
示例6: selectFileSysMg
import org.apache.commons.io.FileSystemUtils; //导入方法依赖的package包/类
/**
* 파일시스템의 크기를 조회한다.
*
* @param fileSysMntrngVO
*/
public int selectFileSysMg(FileSysMntrngVO fileSysMntrngVO) {
try {
FileSystemUtils.freeSpaceKb("");
} catch (IOException e) {
throw new RuntimeException(e);
}
return 0;
}
示例7: getTotalDiskSpace
import org.apache.commons.io.FileSystemUtils; //导入方法依赖的package包/类
public Long getTotalDiskSpace() throws SecurityException, IOException {
try {
long l = ClientFactory.INSTANCE.properties.getMaxStorage();
if (l > 0)
return l;
if (StartStopListener.OPENSEARCHSERVER_DATA_FILE.getClass()
.getDeclaredMethod("getTotalSpace") != null)
return StartStopListener.OPENSEARCHSERVER_DATA_FILE
.getTotalSpace();
} catch (NoSuchMethodException e) {
}
return FileSystemUtils
.freeSpaceKb(StartStopListener.OPENSEARCHSERVER_DATA_FILE
.getAbsolutePath()) * 1000;
}
示例8: home
import org.apache.commons.io.FileSystemUtils; //导入方法依赖的package包/类
public ModelAndView home(HttpServletRequest request, HttpServletResponse httpServletResponse) {
String tenantId = ServletUtils.getSafeParameter(request, "tenantId", "");
String operatorId = ServletUtils.getSafeParameter(request, "operatorId", "");
ModelAndView mav = new ModelAndView("page");
mav.addObject("title", "easyrec :: administration");
mav.addObject("operatorId", operatorId);
mav.addObject("tenantId", tenantId);
if (Security.isDeveloper(request)) {
mav.setViewName("dev/page");
mav.addObject("page", "home");
mav.addObject("operatorCount", operatorDAO.count());
mav.addObject("tenantCount", remoteTenantDAO.count());
mav.addObject("dbName", operatorDAO.getDbName());
mav.addObject("dbUserName", operatorDAO.getDbUserName());
mav.addObject("signedinOperatorId", Security.signedInOperatorId(request));
mav.addObject("heapsize",
ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax() / (1000000));
mav.addObject("usedmemory",
ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() / (1000000));
int computationTimeInMilliseconds = logEntryDAO.getComputationDurationForDate() * 1000;
String computationTime = HumanTime.approximately(computationTimeInMilliseconds);
computationTime = computationTime.replaceAll("ms", "@1");
computationTime = computationTime.replaceAll("s", "@2");
computationTime = computationTime.replaceAll("m", "@3");
computationTime = computationTime.replaceAll("h", "@4");
computationTime = computationTime.replaceAll("d", "@5");
computationTime = computationTime.replaceAll("@1", "milliseconds");
computationTime = computationTime.replaceAll("@2", "seconds");
computationTime = computationTime.replaceAll("@3", "minutes");
computationTime = computationTime.replaceAll("@4", "hours");
computationTime = computationTime.replaceAll("@5", "days");
mav.addObject("dailyComputationTime", computationTime);
long freeSpace = 0L;
try {
freeSpace = FileSystemUtils.freeSpaceKb(System.getProperties().getProperty("user.dir"));
} catch (IOException e) {
logger.error("Could not check free Free Disc Space :" + e.getMessage());
}
mav.addObject("freespace", freeSpace / 1048576);
return mav;
} else {
return MessageBlock.createSingle(mav, MSG.NOT_SIGNED_IN, HOME, MSG.ERROR);
}
}
示例9: get_available_space_apache_commons
import org.apache.commons.io.FileSystemUtils; //导入方法依赖的package包/类
@Test
public void get_available_space_apache_commons () throws IOException {
long freeSpace = FileSystemUtils.freeSpaceKb("/");
assertTrue(freeSpace > 0);
}