本文整理汇总了Java中com.sromku.simple.storage.helpers.SizeUnit类的典型用法代码示例。如果您正苦于以下问题:Java SizeUnit类的具体用法?Java SizeUnit怎么用?Java SizeUnit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SizeUnit类属于com.sromku.simple.storage.helpers包,在下文中一共展示了SizeUnit类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFreeSpace
import com.sromku.simple.storage.helpers.SizeUnit; //导入依赖的package包/类
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
@Override
public long getFreeSpace(SizeUnit sizeUnit) {
String path = buildAbsolutePath();
StatFs statFs = new StatFs(path);
long availableBlocks;
long blockSize;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
availableBlocks = statFs.getAvailableBlocks();
blockSize = statFs.getBlockSize();
} else {
availableBlocks = statFs.getAvailableBlocksLong();
blockSize = statFs.getBlockSizeLong();
}
long freeBytes = availableBlocks * blockSize;
return freeBytes / sizeUnit.inBytes();
}
示例2: getUsedSpace
import com.sromku.simple.storage.helpers.SizeUnit; //导入依赖的package包/类
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
@Override
public long getUsedSpace(SizeUnit sizeUnit) {
String path = buildAbsolutePath();
StatFs statFs = new StatFs(path);
long availableBlocks;
long blockSize;
long totalBlocks;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
availableBlocks = statFs.getAvailableBlocks();
blockSize = statFs.getBlockSize();
totalBlocks = statFs.getBlockCount();
} else {
availableBlocks = statFs.getAvailableBlocksLong();
blockSize = statFs.getBlockSizeLong();
totalBlocks = statFs.getBlockCountLong();
}
long usedBytes = totalBlocks * blockSize - availableBlocks * blockSize;
return usedBytes / sizeUnit.inBytes();
}
示例3: getSize
import com.sromku.simple.storage.helpers.SizeUnit; //导入依赖的package包/类
@Override
public double getSize(File file, SizeUnit unit) {
long length = file.length();
return (double) length / (double) unit.inBytes();
}
示例4: getSize
import com.sromku.simple.storage.helpers.SizeUnit; //导入依赖的package包/类
/**
* Get size of the file in units you need.
*
* @param file
* @param unit
* @return
*/
double getSize(File file, SizeUnit unit);
示例5: getFreeSpace
import com.sromku.simple.storage.helpers.SizeUnit; //导入依赖的package包/类
/**
* Get free space on disk.
*
* @param sizeUnit
* The units you want the returned value to be.
* @return The free space in units you selected.
*/
long getFreeSpace(SizeUnit sizeUnit);
示例6: getUsedSpace
import com.sromku.simple.storage.helpers.SizeUnit; //导入依赖的package包/类
/**
* Get already used space on disk.
*
* @param sizeUnit
* The units you want the returned value to be.
* @return The used space in units you selected.
*/
long getUsedSpace(SizeUnit sizeUnit);