Java Utililty Methods Formatter Usage

List of utility methods to do Formatter Usage

  1. HOME
  2. Java
  3. F
  4. Formatter Usage

Description

The list of methods to do Formatter Usage are organized into topic(s).

Method

String alterationValueToString(double value)
Format percentage.
if (0.0 < value && value <= 0.01) {
 return "<1%";
Formatter f = new Formatter();
f.format("%.0f", value * 100.0);
return f.out().toString() + "%";
Formatter append(final CharSequence seq, final Formatter formatter, final int flags, final int width, final int precision)
Handles the common Formattable operations of truncate-pad-append, with no ellipsis on precision overflow, and padding width underflow with spaces.
return append(seq, formatter, flags, width, precision, ' ', null);
String asFormattedStr(String format, String eol, Object... objects)
as Formatted Str
Formatter f = new Formatter();
String s = f.format(format + "%s", objects, eol).toString();
f.close();
return s;
void assertion(final boolean test, final String fmt, final Object... params)
assertion
if (test) {
 return;
final Formatter f = new Formatter();
throw new RuntimeException(f.format(fmt, params).toString());
String byte2Mac(final byte[] m)
byte Mac
final StringBuilder result = new StringBuilder(17);
final Formatter formatter = new Formatter(result);
formatter.format("%02x:%02x:%02x:%02x:%02x:%02x", m[0], m[1], m[2], m[3], m[4], m[5]);
formatter.close();
return result.toString();
String byteArray2Hex(byte[] hash)
byte Array Hex
Formatter formatter = new Formatter();
for (byte b : hash) {
 formatter.format("%02x", b);
return formatter.toString();
String byteArray2Hex(final byte[] hash)
Converts an input byte array to a hex encoded String.
Formatter formatter = new Formatter();
for (byte b : hash) {
 formatter.format("%02x", b);
return formatter.toString();
String byteArray2HexString(byte[] buf)
byte Array Hex String
return byteArray2HexString(buf, ',');
String byteArrayToHex(final byte[] hash)
Get the hex string representation of a given byte array
String result;
Formatter formatter = new Formatter();
try {
 for (byte b : hash) {
 formatter.format("%02x", b);
 result = formatter.toString();
} catch (Exception lEx) {
...
String byteArrayToHexString(byte[] bytes)
byte Array To Hex String
@SuppressWarnings("resource")
Formatter fmt = new Formatter(new StringBuilder(bytes.length * 2));
for (byte b : bytes) {
 fmt.format("%02x", b);
return fmt.toString();


AltStyle によって変換されたページ (->オリジナル) /