本文整理匯總了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();
}