當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。