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


Java FileStore.getTotalSpace方法代码示例

本文整理汇总了Java中java.nio.file.FileStore.getTotalSpace方法的典型用法代码示例。如果您正苦于以下问题:Java FileStore.getTotalSpace方法的具体用法?Java FileStore.getTotalSpace怎么用?Java FileStore.getTotalSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.nio.file.FileStore的用法示例。


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

示例1: sendDiskEvent

import java.nio.file.FileStore; //导入方法依赖的package包/类
private void sendDiskEvent(Path root) {
    try {
        FileStore store = Files.getFileStore(root);

        long totalSpace = store.getTotalSpace();
        long usableSpace = store.getUsableSpace();
        long unallocatedSpace = store.getUnallocatedSpace();

        OsEventBuilder eventBuilder = OsEventBuilder.createDiskBuilder(this.getEventBuilderData());

        eventBuilder.setDiskPath(root.toString());
        eventBuilder.setTotalDiskSpace(totalSpace);
        eventBuilder.setUsableDiskSpace(usableSpace);
        eventBuilder.setUnallocatedDiskSpace(unallocatedSpace);
        eventBuilder.setUsedDiskSpace(totalSpace - unallocatedSpace);

        this.sendEvent(eventBuilder.toEvent());
    } catch (Exception e) {
        // ignore
    }
}
 
开发者ID:Indoqa,项目名称:logspace,代码行数:22,代码来源:DiskAgent.java

示例2: addContext

import java.nio.file.FileStore; //导入方法依赖的package包/类
@Override
public TypedMap addContext(final TypedMap existing)
{
    try {
        // Determine the file store for the directory the JVM was started in
        FileStore fileStore = Files.getFileStore(Paths.get(System.getProperty("user.dir")));

        long size = fileStore.getTotalSpace();
        long gb_size = size/(K*K*K);
        return ImmutableTypedMap.Builder.from(existing).add(DISK_SIZE, Long.valueOf(gb_size)).build();
    } catch (IOException e) {
        // log?
        return existing;
    }
}
 
开发者ID:awslabs,项目名称:swage,代码行数:16,代码来源:DiskUsageSensor.java

示例3: sense

import java.nio.file.FileStore; //导入方法依赖的package包/类
@Override
public void sense(final MetricRecorder.Context metricContext) throws SenseException
{
    try {
        // Determine the file store for the directory the JVM was started in
        FileStore fileStore = Files.getFileStore(Paths.get(System.getProperty("user.dir")));

        long total = fileStore.getTotalSpace();
        long free = fileStore.getUsableSpace();
        double percent_free = 100.0 * ((double)(total-free)/(double)total);
        metricContext.record(DISK_USED, percent_free, Unit.PERCENT);
    } catch (IOException e) {
        throw new SenseException("Problem reading disk space", e);
    }
}
 
开发者ID:awslabs,项目名称:swage,代码行数:16,代码来源:DiskUsageSensor.java

示例4: Volume

import java.nio.file.FileStore; //导入方法依赖的package包/类
/**
 * A constructor to create a Volume object from a FileStore object.
 *
 * @param root
 * @param fileStore
 */
public Volume(String root, FileStore fileStore)
{
    label = fileStore.name(); //TODO VolumeLabel;
    name = fileStore.name();
    type = fileStore.type();
    format = fileStore.type(); // TODO DriveFormat
    path = root; // ex. C:\

    try {
        size = fileStore.getTotalSpace();
        free = fileStore.getUsableSpace();
    }
    catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:ciphertechsolutions,项目名称:IO,代码行数:23,代码来源:Volume.java

示例5: get

import java.nio.file.FileStore; //导入方法依赖的package包/类
@Override
public Space get() throws BackgroundException {
    final Path home = new DefaultHomeFinderService(session).find();
    try {
        final FileStore store = Files.getFileStore(session.toPath(home));
        return new Space(store.getTotalSpace() - store.getUnallocatedSpace(), store.getUnallocatedSpace());
    }
    catch(IOException e) {
        throw new LocalExceptionMappingService().map("Failure to read attributes of {0}", e, home);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:12,代码来源:LocalQuotaFeature.java

示例6: getTotalSpace

import java.nio.file.FileStore; //导入方法依赖的package包/类
public long getTotalSpace() {
    long totalSpace = 0;
    try {
        FileStore fileStore = Files.getFileStore(Paths.get("."));
        totalSpace = fileStore.getTotalSpace();
    } catch (IOException ioEx) {
        logger.log(Level.WARNING, "Cannot calculate free disk space", ioEx);
    }

    return totalSpace;
}
 
开发者ID:games647,项目名称:LagMonitor,代码行数:12,代码来源:NativeData.java

示例7: freeSpace

import java.nio.file.FileStore; //导入方法依赖的package包/类
private Double freeSpace ()
{
    try
    {
        final String base = System.getProperty ( SYSPROP_STORAGE_BASE );
        final Path p = Paths.get ( base );

        final FileStore store = Files.getFileStore ( p );
        return (double)store.getUnallocatedSpace () / (double)store.getTotalSpace ();
    }
    catch ( final Exception e )
    {
        return null;
    }
}
 
开发者ID:eclipse,项目名称:packagedrone,代码行数:16,代码来源:ConfigController.java

示例8: getTotalSpace

import java.nio.file.FileStore; //导入方法依赖的package包/类
public long getTotalSpace() {
    long result = 0;
    for (FileStore store : FileSystems.getDefault().getFileStores()) {
        try {
            result += store.getTotalSpace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return result;
}
 
开发者ID:disit,项目名称:sce-backend,代码行数:12,代码来源:SchedulerLoggerStatus.java

示例9: getFsStat

import java.nio.file.FileStore; //导入方法依赖的package包/类
@Override
public FsStat getFsStat() throws IOException {
    FileStore store = Files.getFileStore(_root);
    long total = store.getTotalSpace();
    long free = store.getUsableSpace();
    return new FsStat(total, Long.MAX_VALUE, total-free, pathToInode.size());
}
 
开发者ID:kofemann,项目名称:simple-nfs,代码行数:8,代码来源:LocalFileSystem.java

示例10: calculateUsage

import java.nio.file.FileStore; //导入方法依赖的package包/类
protected double calculateUsage(FileStore store) throws IOException {
   return 1.0 - (double) store.getUsableSpace() / (double) store.getTotalSpace();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:4,代码来源:FileStoreMonitor.java

示例11: get_file_store_total_space

import java.nio.file.FileStore; //导入方法依赖的package包/类
@Test
public void get_file_store_total_space () throws IOException {

	FileStore store = Files.getFileStore(source);

	long totalSpace = store.getTotalSpace();
	
	assertTrue(totalSpace > 0);
}
 
开发者ID:wq19880601,项目名称:java-util-examples,代码行数:10,代码来源:GetTotalSpace.java

示例12: get_used_space_nio

import java.nio.file.FileStore; //导入方法依赖的package包/类
@Test
public void get_used_space_nio () throws IOException {

	FileStore store = Files.getFileStore(source);

	long usedSpace = (store.getTotalSpace() -
             store.getUnallocatedSpace()) / 1024;
	
	assertTrue(usedSpace > 0);
}
 
开发者ID:wq19880601,项目名称:java-util-examples,代码行数:11,代码来源:GetUsedSpace.java


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