Here you can find the source of getStorageName(final File file)
Parameter | Description |
---|---|
file | the file. |
Parameter | Description |
---|---|
IOException | I/O exception. |
public static String getStorageName(final File file) throws IOException
//package com.java2s; import java.io.File; import java.io.IOException; import java.nio.file.FileStore; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class Main { /**/*from w ww . j a v a2 s . c om*/ * Returns a storage name (volume name). * * @param file * the file. * @return the storage name (volume name). * @throws IOException * I/O exception. */ public static String getStorageName(final File file) throws IOException { Path path = Paths.get(file.getPath()); FileStore fs = Files.getFileStore(path); String storageName = fs.name(); return storageName; } }