当前位置: 首页>>代码示例>>Java>>正文


Java SizeUnit类代码示例

本文整理汇总了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();
}
 
开发者ID:chemickypes,项目名称:Glitchy,代码行数:19,代码来源:AbstractDiskStorage.java

示例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();
}
 
开发者ID:chemickypes,项目名称:Glitchy,代码行数:22,代码来源:AbstractDiskStorage.java

示例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();
}
 
开发者ID:chemickypes,项目名称:Glitchy,代码行数:6,代码来源:AbstractDiskStorage.java

示例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);
 
开发者ID:chemickypes,项目名称:Glitchy,代码行数:9,代码来源:Storage.java

示例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);
 
开发者ID:chemickypes,项目名称:Glitchy,代码行数:9,代码来源:Storage.java

示例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);
 
开发者ID:chemickypes,项目名称:Glitchy,代码行数:9,代码来源:Storage.java


注:本文中的com.sromku.simple.storage.helpers.SizeUnit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。