long getPreferredBlockSize ( String filename ) throws IOException { byte [ ] [ ] components = INodeDirectory . getPathComponents ( filename ) ; readLock ( ) ; try { INode fileNode = rootDir . getNode ( components ) ; if ( fileNode == null ) { throw new IOException ( "Unknown file: " + filename ) ; } if ( fileNode . isDirectory ( ) ) { throw new IOException ( "Getting block size of a directory: " + filename ) ; } return ( ( INodeFile ) fileNode ) . getPreferredBlockSize ( ) ; } finally { readUnlock ( ) ; } }
Get the blocksize of a file