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


Java Files.getFileStore方法代码示例

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


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

示例1: getFileStoreType

import java.nio.file.Files; //导入方法依赖的package包/类
/**
 * Get the file store type of a path. for example, /dev/sdd1(store name) /w2-gst-dev40d(mount
 * point) ext4(type)
 * 
 * @param path
 * @return file store type
 */
public String getFileStoreType(final String path) {
  File diskFile = new File(path);
  if (!diskFile.exists()) {
    diskFile = diskFile.getParentFile();
  }
  Path currentPath = diskFile.toPath();
  if (currentPath.isAbsolute() && Files.exists(currentPath)) {
    try {
      FileStore store = Files.getFileStore(currentPath);
      return store.type();
    } catch (IOException e) {
      return null;
    }
  }
  return null;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:24,代码来源:NativeCallsJNAImpl.java

示例2: addContext

import java.nio.file.Files; //导入方法依赖的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.Files; //导入方法依赖的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: provideRootFileStore

import java.nio.file.Files; //导入方法依赖的package包/类
@Provides
@PerAdapter
protected FileStore provideRootFileStore() {
	try {
		return Files.getFileStore(root);
	} catch (IOException e) {
		throw new UncheckedIOException(e);
	}
}
 
开发者ID:cryptomator,项目名称:fuse-nio-adapter,代码行数:10,代码来源:FuseNioAdapterModule.java

示例5: getUsableDiscSpaceInGB

import java.nio.file.Files; //导入方法依赖的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: get

import java.nio.file.Files; //导入方法依赖的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

示例7: MyDefHealthIndicator

import java.nio.file.Files; //导入方法依赖的package包/类
@Autowired
public MyDefHealthIndicator(
        @Value("${health.filestore.path:/}") String path,
        @Value("${health.filestore.threshold.bytes:10485760}") long thresholdBytes) 
                throws IOException {
    fileStore = Files.getFileStore(Paths.get(path));
    this.thresholdBytes = thresholdBytes;
}
 
开发者ID:hutou-workhouse,项目名称:miscroServiceHello,代码行数:9,代码来源:MyDefHealthIndicator.java

示例8: testFileStore

import java.nio.file.Files; //导入方法依赖的package包/类
@Test
public void testFileStore() throws Exception {
  Path path = Paths.get(".");
  //System.out.println(path.toAbsolutePath());
  FileStore fStore = Files.getFileStore(path);
  //System.out.println(fStore);
}
 
开发者ID:EHRI,项目名称:rs-aggregator,代码行数:8,代码来源:PathFinderTest.java

示例9: ZipFileStoreAttributes

import java.nio.file.Files; //导入方法依赖的package包/类
public ZipFileStoreAttributes(ZipFileStore fileStore)
    throws IOException
{
    Path path = FileSystems.getDefault().getPath(fileStore.name());
    this.size = Files.size(path);
    this.fstore = Files.getFileStore(path);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:ZipFileStore.java

示例10: getFileStores

import java.nio.file.Files; //导入方法依赖的package包/类
@Override
public Iterable<FileStore> getFileStores() {
    FileStore store;
    try {
        store = Files.getFileStore(root);
    } catch (IOException ioe) {
        store = null;
    }
    return SoleIterable(store);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:FaultyFileSystem.java

示例11: getMatchingFileStore

import java.nio.file.Files; //导入方法依赖的package包/类
/** 
 * Files.getFileStore(Path) useless here!  Don't complain, just try it yourself. 
 */
@SuppressForbidden(reason = "works around the bugs")
static FileStore getMatchingFileStore(Path path, FileStore fileStores[]) throws IOException {       
    if (Constants.WINDOWS) {
        return getFileStoreWindows(path, fileStores);
    }
    
    final FileStore store;
    try {
        store = Files.getFileStore(path);
    } catch (IOException unexpected) {
        // give a better error message if a filestore cannot be retrieved from inside a FreeBSD jail.
        if (Constants.FREE_BSD) {
            throw new IOException("Unable to retrieve mount point data for " + path +
                                  ". If you are running within a jail, set enforce_statfs=1. See jail(8)", unexpected);
        } else {
            throw unexpected;
        }
    }

    try {
        String mount = getMountPointLinux(store);
        FileStore sameMountPoint = null;
        for (FileStore fs : fileStores) {
            if (mount.equals(getMountPointLinux(fs))) {
                if (sameMountPoint == null) {
                    sameMountPoint = fs;
                } else {
                    // more than one filesystem has the same mount point; something is wrong!
                    // fall back to crappy one we got from Files.getFileStore
                    return store;
                }
            }
        }

        if (sameMountPoint != null) {
            // ok, we found only one, use it:
            return sameMountPoint;
        } else {
            // fall back to crappy one we got from Files.getFileStore
            return store;    
        }
    } catch (Exception e) {
        // ignore
    }

    // fall back to crappy one we got from Files.getFileStore
    return store;    
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:52,代码来源:ESFileStore.java

示例12: getFileStore

import java.nio.file.Files; //导入方法依赖的package包/类
@Override
public FileStore getFileStore(Path file) throws IOException {
    triggerEx(file, "getFileStore");
    return Files.getFileStore(unwrap(file));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:FaultyFileSystem.java


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