本文整理汇总了Java中org.apache.commons.io.FileUtils.byteCountToDisplaySize方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.byteCountToDisplaySize方法的具体用法?Java FileUtils.byteCountToDisplaySize怎么用?Java FileUtils.byteCountToDisplaySize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.io.FileUtils
的用法示例。
在下文中一共展示了FileUtils.byteCountToDisplaySize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setStepResult
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
* Sets panel's content. If content has been set already it is discarded.
*
* @param activeBuildID
* @param am
* @param stepResult
* @param showDescription
*/
public void setStepResult(final int activeBuildID, final ArchiveManager am,
final StepResult stepResult, final boolean showDescription) {
//clear
clear();
if (showDescription) {
// add desciption
add(new CommonLabel(stepResult.getDescription() + ':'));
}
final byte pathType = stepResult.getPathType();
if (pathType == StepResult.PATH_TYPE_DIR || pathType == StepResult.PATH_TYPE_SINGLE_FILE) {
// show file list
try {
final List entries = am.getArchivedResultEntries(stepResult);
for (final Iterator j = entries.iterator(); j.hasNext();) {
final ArchiveEntry archiveEntry = (ArchiveEntry) j.next();
final CommonLink lnkResult = makeResultLink(stepResult, archiveEntry.getEntryName(), activeBuildID);
final CommonLabel lbByteCount = new CommonLabel(FileUtils.byteCountToDisplaySize(archiveEntry.getLength()));
add(new CommonFlow(lnkResult, new Label(" "), lbByteCount));
}
} catch (IOException e) {
reportArchiveReadingError(e);
}
} else if (pathType == StepResult.PATH_TYPE_EXTERNAL_URL) {
// show URL stored in the result path
final CommonLink lnk = new CommonLink(stepResult.getPath(), stepResult.getPath());
lnk.setTarget("_blank");
add(lnk);
} else {
// unknown type
reportUnknownPathType(pathType, activeBuildID);
}
}
示例2: getValue
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
* Get value for the given route point
*
* @param point
* @return value
*/
public Object getValue(final AbstractPacketPoint point) {
switch (this) {
case NUMBER:
return point.getNumber();
case COUNTRY_FLAG:
return point.getCountryFlag(Resolution.R16);
case LOCATION:
return getText(point);
case PROTOCOL:
return point.getProtocol();
case DEST_IP:
return point.getIp();
case DEST_HOSTNAME:
return point.getHostname();
case DEST_PORT:
return point.getDestPort();
case SRC_PORT:
return point.getSourcePort();
case TIME:
return point.getDate();
case DATA_LENGTH:
return FileUtils.byteCountToDisplaySize(point.getDataLength());
case WHO_IS:
return point.getIp();
default:
return null;
}
}
示例3: onCreateDialog
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
View view = new DialogHelper.Builder(getActivity())
.setTitle(R.string.info)
.setView(R.layout.dialog_fragment_file_info)
.createSkeletonView();
//final View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_fragment_file_info, null);
ListView list = (ListView) view.findViewById(android.R.id.list);
DocumentFile file = DocumentFile.fromFile(new File(AccessStorageApi.getPath(getActivity(), (Uri) getArguments().getParcelable("uri"))));
if (file == null && Device.hasKitKatApi()) {
file = DocumentFile.fromSingleUri(getActivity(), (Uri) getArguments().getParcelable("uri"));
}
// Get the last modification information.
Long lastModified = file.lastModified();
// Create a new date object and pass last modified information
// to the date object.
Date date = new Date(lastModified);
String[] lines1 = {
getString(R.string.name),
//getString(R.string.folder),
getString(R.string.size),
getString(R.string.modification_date)
};
String[] lines2 = {
file.getName(),
//file.getParent(),
FileUtils.byteCountToDisplaySize(file.length()),
date.toString()
};
list.setAdapter(new AdapterTwoItem(getActivity(), lines1, lines2));
return new AlertDialog.Builder(getActivity())
.setView(view)
.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}
)
.create();
}