FileStore getBlockSize() method in Java with Examples Last Updated : 03 Dec, 2019 Comments Improve Suggest changes Like Article Like Report The getBlockSize() method of a FileStore class is used to return the number of bytes per block in this file store Object. Every File storage is organized into discrete sequences of bytes called blocks and a block is the smallest storage unit of a file store. Every read and write operation is performed on multiple blocks. This method is helpful in getting the size of Block. Syntax: public long getBlockSize() throws IOException Parameters: This method accepts nothing. Return value: This method returns a positive value representing the block size of this file store, in bytes. Exception: This method throws following Exceptions: IOException: if an I/O error occurs. UnsupportedOperationException: if the operation is not supported. Below programs illustrate the getBlockSize() method: Program 1: Java // Java program to demonstrate // FileStore.getBlockSize() method 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 GFG { public static void main(String[] args) throws IOException { // create object of Path Path path = Paths.get( "C:\\Movies\\001.txt"); // get FileStore object FileStore fs = Files.getFileStore(path); // print FileStore name and // getBlockSize System.out.println("FileStore Name: " + fs.name()); System.out.println("Block Size:" + fs.getBlockSize()); } } Output: Program 2: Java // Java program to demonstrate // FileStore.getBlockSize() method 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 GFG { public static void main(String[] args) throws IOException { // create object of Path Path path = Paths.get( "E:\\Tutorials\\file.txt"); // get FileStore object FileStore fs = Files.getFileStore(path); // print FileStore name and // getBlockSize System.out.println("FileStore Name: " + fs.name()); System.out.println("Block Size:" + fs.getBlockSize()); } } Output: References: https://docs.oracle.com/javase/10/docs/api/java/nio/file/FileStore.html#getBlockSize() Comment More infoAdvertise with us Next Article FileStore getBlockSize() method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java-Functions java.nio.file package Java-FileStore Practice Tags : Java Similar Reads FileStore getUsableSpace() method in Java with Examples The getUsableSpace() method of a FileStore class is used to return the number of bytes available to this Java virtual machine on the file store. This method is useful to check free space. This method returns the available usable space as a long value. Syntax: public abstract long getUsableSpace() th 2 min read FileStore getTotalSpace() method in Java with Examples The getTotalSpace() method of a FileStore class is used to return total size of the file store, in bytes. This method returns this total size as a long value. Syntax: public abstract long getTotalSpace() throws IOException Parameters: This method accepts nothing. Return value: This method returns th 2 min read FileStore getUnallocatedSpace() method in Java with Examples The getUnallocatedSpace() method of a FileStore class is used to get the number of unallocated bytes in the file store. This method is useful to check free space. This method returns the available unallocated space as a long value.Syntax: public abstract long getUnallocatedSpace() throws IOException 2 min read Files getFileStore() method in Java with Examples getFileStore() method of java.nio.file.Files help us to return the FileStore object which represents the file store where a file is located. Once you get a reference to the FileStore you can apply filestore type of operation to get information of filestore. Syntax: public static FileStore getFileSto 2 min read File getUsableSpace() method in java with examples The getUsableSpace() function is a part of File class in Java . This function returns the unallocated size of the partition denoted by the abstract pathname, if the pathname does not exist then it returns 0L. This function is more accurate than the getFreeSpace() function as it returns the free spac 2 min read Like