Example usage for java.nio.file FileStore type

List of usage examples for java.nio.file FileStore type

Introduction

In this page you can find the example usage for java.nio.file FileStore type.

Prototype

public abstract String type();

Source Link

Document

Returns the type of this file store.

Usage

From source file:Main.java

public static void main(String[] args) throws IOException {
    FileSystem fileSystem = FileSystems.getDefault();

    for (FileStore store : fileSystem.getFileStores()) {
        System.out.println(store.type());
    }//from w ww . j a  v  a 2  s.c  o m
}

From source file:Test.java

public static void main(String[] args) throws Exception {
    FileSystem fileSystem = FileSystems.getDefault();

    for (FileStore fileStore : fileSystem.getFileStores()) {
        long totalSpace = fileStore.getTotalSpace() / kiloByte;
        long usedSpace = (fileStore.getTotalSpace() - fileStore.getUnallocatedSpace()) / kiloByte;
        long usableSpace = fileStore.getUsableSpace() / kiloByte;
        String name = fileStore.name();
        String type = fileStore.type();
        boolean readOnly = fileStore.isReadOnly();
    }//from   w ww.  j  a  v  a 2s .  co m
}

From source file:Main.java

public static void printDetails(FileStore store) {
    try {//from ww w . j av  a  2 s .  c o  m
        String desc = store.toString();
        String type = store.type();
        long totalSpace = store.getTotalSpace();
        long unallocatedSpace = store.getUnallocatedSpace();
        long availableSpace = store.getUsableSpace();
        System.out.println(desc + ", Total: " + totalSpace + ",  Unallocated: " + unallocatedSpace
                + ",  Available: " + availableSpace);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:fr.ortolang.diffusion.store.binary.BinaryStoreServiceBean.java

@Override
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
public List<BinaryStoreContent> systemBrowse(String name, String prefix) throws BinaryStoreServiceException {
    if (name == null || name.length() == 0) {
        List<BinaryStoreContent> vinfos = new ArrayList<BinaryStoreContent>();
        List<String> vnames = new ArrayList<String>();
        vnames.addAll(BinaryStoreVolumeMapper.listVolumes());
        vnames.add(WORK);// w w  w  . jav a2  s.c om
        for (String vname : vnames) {
            try {
                BinaryStoreContent volume = new BinaryStoreContent();
                Path vpath = Paths.get(base.toString(), vname);
                FileStore vstore = Files.getFileStore(vpath);
                volume.setPath(vname);
                volume.setType(Type.VOLUME);
                volume.setFsName(vstore.name());
                volume.setFsType(vstore.type());
                volume.setFsTotalSize(vstore.getTotalSpace());
                volume.setFsFreeSize(vstore.getUsableSpace());
                volume.setSize(Files.size(vpath));
                volume.setLastModificationDate(Files.getLastModifiedTime(vpath).toMillis());
                vinfos.add(volume);
            } catch (IOException e) {
                LOGGER.log(Level.WARNING,
                        "Unable to retrieve binary store volume information for volume: " + vname);
            }
        }
        return vinfos;
    } else {
        try {
            if (prefix == null) {
                prefix = "";
            }
            Path vpath = Paths.get(base.toString(), name, prefix);
            if (!Files.exists(vpath)) {
                throw new BinaryStoreServiceException(
                        "volume name does not point to an existing file or a directory");
            }
            return Files.list(vpath).map(this::pathToContent).collect(Collectors.toList());
        } catch (IOException e) {
            throw new BinaryStoreServiceException(e);
        }
    }
}