List of usage examples for java.util Formatter toString
public String toString()
From source file:com.codealot.textstore.FileStore.java
private static String byteToHex(final byte[] hash) { final Formatter formatter = new Formatter(); for (final byte b : hash) { formatter.format("%02X", b); }/*from w w w.j a va2 s. co m*/ final String result = formatter.toString(); formatter.close(); return result; }
From source file:wptools.cmds.DumpCerts.java
private static String formatFing(final byte[] fing) { if (fing == null) return "(null)"; if (fing.length == 0) return "(empty)"; Formatter fmt = new Formatter(); boolean needColon = false; for (byte b : fing) { if (needColon) fmt.format("%c", ':'); else// w w w.j a v a 2s . co m needColon = true; fmt.format("%02X", b); } return fmt.toString(); }
From source file:org.openecomp.sdc.common.config.EcompErrorLogUtil.java
private static Either<String, Boolean> setDescriptionParams(EcompErrorEnum ecompErrorEnum, String... descriptionParams) { String description = ecompErrorEnum.getEcompErrorCode().getDescription(); // Counting number of params in description int countMatches = StringUtils.countMatches(description, AbsEcompErrorManager.PARAM_STR); // Catching cases when there are more params passed than there are in // the description (formatter will ignore extra params and won't throw // exception) if (countMatches != descriptionParams.length) { return Either.right(false); }/* w w w . java 2 s . c o m*/ // Setting params of the description if any StringBuilder sb = new StringBuilder(); Formatter formatter = new Formatter(sb, Locale.US); try { formatter.format(description, (Object[]) descriptionParams).toString(); return Either.left(formatter.toString()); } catch (IllegalFormatException e) { // Number of passed params doesn't match number of params in config // file return Either.right(false); } finally { formatter.close(); } }
From source file:com.codedx.burp.security.InvalidCertificateDialogStrategy.java
public static String toHexString(byte[] bytes, String sep) { Formatter f = new Formatter(); for (int i = 0; i < bytes.length; i++) { f.format("%02x", bytes[i]); if (i < bytes.length - 1) { f.format(sep);//from w ww . ja v a 2 s .co m } } String result = f.toString(); f.close(); return result; }
From source file:Networking.Server.java
private static String toHexString(byte[] bytes) { Formatter formatter = new Formatter(); for (byte b : bytes) { formatter.format("%02x", b); }//w ww . jav a 2 s .com return formatter.toString(); }
From source file:org.sourcepit.tpmp.change.ChecksumTargetPlatformConfigurationChangeDiscoverer.java
private static String byteArray2Hex(byte[] hash) { Formatter formatter = null; try {/*from w w w . j a v a2 s. c o m*/ formatter = new Formatter(); for (byte b : hash) { formatter.format("%02x", Byte.valueOf(b)); } return formatter.toString(); } finally { IOUtils.closeQuietly(formatter); } }
From source file:com.lightbox.android.bitmap.BitmapUtils.java
private static String md5ToString(byte[] md5Hash) { Formatter formatter = new Formatter(); for (byte b : md5Hash) { formatter.format("%02x", b); }//from ww w . j a v a 2 s. c o m return formatter.toString(); }
From source file:com.lightbox.android.bitmap.BitmapUtils.java
private static String getMD5String(byte[] data) { MessageDigest md5 = null;/* w w w . j a v a 2 s .co m*/ try { md5 = MessageDigest.getInstance("MD5"); md5.reset(); md5.update(data); byte[] md5Hash = md5.digest(); Formatter formatter = new Formatter(); for (byte b : md5Hash) { formatter.format("%02x", b); } return formatter.toString(); } catch (NoSuchAlgorithmException e1) { Log.w(TAG, e1); } return ""; }
From source file:de.uzk.hki.da.pkg.MetsConsistencyChecker.java
/** * Byte array2 hex./*from w w w . ja va2 s .com*/ * * @param hash the hash * @return the string */ private static String byteArray2Hex(byte[] hash) { Formatter formatter = new Formatter(); for (byte b : hash) { formatter.format("%02x", b); } String result = formatter.toString(); formatter.close(); return result; }
From source file:com.base.service.WeixinService.java
private static String byteToHex(final byte[] hash) { Formatter formatter = new Formatter(); for (byte b : hash) { formatter.format("%02x", b); }/* w w w .ja va2 s . c o m*/ String result = formatter.toString(); formatter.close(); return result; }