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


Java FileStore.getUsableSpace方法代码示例

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


在下文中一共展示了FileStore.getUsableSpace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getFreeDiskSpace

import java.nio.file.FileStore; //导入方法依赖的package包/类
/**
 * Get the free disk space for a selected path.
 *
 * @return Free disk space in bytes.
 */
private long getFreeDiskSpace(final String strPath) {
    long usableSpace = 0;
    if (!strPath.isEmpty()) {
        try {
            Path path = Paths.get(strPath);
            if (!Files.exists(path)) {
                path = path.getParent();
            }
            final FileStore fileStore = Files.getFileStore(path);
            usableSpace = fileStore.getUsableSpace();
        } catch (Exception ignore) {
        }
    }
    return usableSpace;
}
 
开发者ID:mediathekview,项目名称:MediathekView,代码行数:21,代码来源:DialogAddDownload.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: getUsableDiscSpaceInGB

import java.nio.file.FileStore; //导入方法依赖的package包/类
/**
 * @return returns available disc space in GB
 * @throws IOException
 *
 */
public static Long getUsableDiscSpaceInGB() throws IOException {
    Path path = Paths.get(System.getProperty("user.dir"));

    //Retrieve the mounted file system on which vmidc files are stored
    FileStore store = Files.getFileStore(path);

    return store.getUsableSpace() / 1024 / 1024 / 1024;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:14,代码来源:ServerUtil.java

示例6: getFreeSpace

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

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

示例7: getUsableSpace

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

示例8: getFileStores

import java.nio.file.FileStore; //导入方法依赖的package包/类
/**
 * Simple test to check {@link FileStore} support.
 *
 * @throws IOException
 */
@Test
public void getFileStores() throws IOException {
  Path pathToTest = Paths.get(clusterUri);

  Iterable<FileStore> fileStores = pathToTest.getFileSystem().getFileStores();
  for (FileStore store : fileStores) {
    store.getUsableSpace();
    assertNotNull(store.toString());
  }
}
 
开发者ID:damiencarol,项目名称:jsr203-hadoop,代码行数:16,代码来源:TestFileSystem.java

示例9: testFileStoreLimitPreventsFileCreation

import java.nio.file.FileStore; //导入方法依赖的package包/类
@Test
@Category( { FileStores.class, SizeLimit.class, Exclusive.class, Writable.class } )
public void testFileStoreLimitPreventsFileCreation() throws IOException {

    FileStore store = sizeLimitedRoot().getFileSystem().provider().getFileStore( sizeLimitedRoot() );

    while( store.getUsableSpace() > 20000 ) {
        Files.write( sizeLimitedRoot().resolve( UUID.randomUUID().toString() ), CONTENT_BIG );
    }

    assertThatThrownBy( () -> Files.write( sizeLimitedRoot().resolve( UUID.randomUUID().toString() ), CONTENT_BIG ) ).
            isInstanceOf( IOException.class );
}
 
开发者ID:openCage,项目名称:niotest,代码行数:14,代码来源:Tests13FileStore.java

示例10: testFileStoreLimitPreventsFileModification

import java.nio.file.FileStore; //导入方法依赖的package包/类
@Test
@Category( { FileStores.class, SizeLimit.class, Exclusive.class, Writable.class } )
public void testFileStoreLimitPreventsFileModification() throws IOException {

    FileStore store = sizeLimitedRoot().getFileSystem().provider().getFileStore( sizeLimitedRoot() );

    while( store.getUsableSpace() > 20000 ) {
        Files.write( sizeLimitedRoot().resolve( UUID.randomUUID().toString() ), CONTENT_BIG );
    }

    assertThatThrownBy( () -> Files.write( fileInLimitedPlayground(), CONTENT_BIG, StandardOpenOption.APPEND ) ).
            isInstanceOf( IOException.class );
}
 
开发者ID:openCage,项目名称:niotest,代码行数:14,代码来源:Tests13FileStore.java

示例11: testFileStoreLimitPreventsCopy

import java.nio.file.FileStore; //导入方法依赖的package包/类
@Test
@Category( { FileStores.class, SizeLimit.class, Exclusive.class } )
public void testFileStoreLimitPreventsCopy() throws IOException {

    FileStore store = sizeLimitedRoot().getFileSystem().provider().getFileStore( sizeLimitedRoot() );

    while( store.getUsableSpace() > 20000 ) {
        Files.write( sizeLimitedRoot().resolve( UUID.randomUUID().toString() ), CONTENT_BIG );
    }

    Path target = sizeLimitedRoot().resolve( "target" );

    assertThatThrownBy( () -> Files.copy( fileInLimitedPlayground(), target ) ).
                        isInstanceOf( IOException.class );
}
 
开发者ID:openCage,项目名称:niotest,代码行数:16,代码来源:Tests13FileStore.java

示例12: 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

示例13: freeDiskBytes

import java.nio.file.FileStore; //导入方法依赖的package包/类
public long freeDiskBytes() throws IOException {
    Iterable<FileStore> fileStores = localFileSystem.getFileStores();
    long totalUsableSpace = 0l;
    for(FileStore fs:fileStores){
        totalUsableSpace+=fs.getUsableSpace();
    }
    return totalUsableSpace;
}
 
开发者ID:splicemachine,项目名称:spliceengine,代码行数:9,代码来源:FileSystemConfiguration.java

示例14: freeSpaceFormatted

import java.nio.file.FileStore; //导入方法依赖的package包/类
public static String freeSpaceFormatted(FileStore store) throws Exception {
	long mb = store.getUsableSpace() / (1000*1000); // 10^6 converts to megabytes.
	return mb + " mb";
}
 
开发者ID:a-r-d,项目名称:java-1-class-demos,代码行数:5,代码来源:FileStoreBasics.java

示例15: 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


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