当前位置: 首页>>代码示例>>Java>>正文


Java FileSystemUtils类代码示例

本文整理汇总了Java中org.apache.commons.io.FileSystemUtils的典型用法代码示例。如果您正苦于以下问题:Java FileSystemUtils类的具体用法?Java FileSystemUtils怎么用?Java FileSystemUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileSystemUtils类属于org.apache.commons.io包,在下文中一共展示了FileSystemUtils类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import org.apache.commons.io.FileSystemUtils; //导入依赖的package包/类
@Override
public void start() throws Exception {
	service.scheduleWithFixedDelay(new Runnable() {
		public void run() {

			long freeSpace;
			try {
				freeSpace = FileSystemUtils.freeSpaceKb(path);
				if (freeSpace <= diskFullKBActivation) {
					// run disk full action
					collectorAction.exec();

				}
			} catch (Throwable t) {
				LOG.error(t.toString(), t);
			}

		}
	}, initialDelay, frequency, TimeUnit.MILLISECONDS);

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:22,代码来源:DiskSpaceCheckService.java

示例2: 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;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:24,代码来源:ExtractorUtils.java

示例3: 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;
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:22,代码来源:MonitorProvider.java

示例4: 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;
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:21,代码来源:Monitor.java

示例5: 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;
	}
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:9,代码来源:StatusUpdaterThread.java

示例6: getDiskSpace

import org.apache.commons.io.FileSystemUtils; //导入依赖的package包/类
private String getDiskSpace() {
	try {
		return String.valueOf(FileSystemUtils.freeSpaceKb("/"));
	} catch (IOException e) {
		LOG.error(e.toString(), e);
		return "-1";
	}
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:9,代码来源:StatusExtrasBuilder.java

示例7: 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;
	}
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:9,代码来源:StatusUpdaterThread.java

示例8: getDiskSpace

import org.apache.commons.io.FileSystemUtils; //导入依赖的package包/类
private String getDiskSpace() {
	try {
		return String.valueOf(FileSystemUtils.freeSpaceKb(dataDir));
	} catch (IOException e) {
		LOG.error(e.toString(), e);
		return "-1";
	}
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:9,代码来源:StatusExtrasBuilder.java

示例9: 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;
}
 
开发者ID:aramsoft,项目名称:aramcomp,代码行数:14,代码来源:FileSysMntrngService.java

示例10: 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;
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:16,代码来源:Monitor.java

示例11: testFileSystemUtils

import org.apache.commons.io.FileSystemUtils; //导入依赖的package包/类
/**
    * @throws Exception
    */
   @SuppressWarnings("deprecation")
@Test
   public void testFileSystemUtils() throws Exception {
   	
   	try {
   		long freeSpace = FileSystemUtils.freeSpace("C:/");

   		assertTrue(freeSpace > 0);

   	} catch (Exception e) {
   		log.error(e.getCause());
   	}
   }
 
开发者ID:eGovFrame,项目名称:egovframework.rte.root,代码行数:17,代码来源:FilehandlingServiceTest.java

示例12: 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);
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:56,代码来源:InfoController.java

示例13: 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);
}
 
开发者ID:wq19880601,项目名称:java-util-examples,代码行数:8,代码来源:GetAvailableSpace.java


注:本文中的org.apache.commons.io.FileSystemUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。