Java Hex Format formatHexStr(int width, String hexStr)

Here you can find the source of formatHexStr(int width, String hexStr)

Description

format Hex Str

License

Open Source License

Declaration

public static String formatHexStr(int width, String hexStr) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static String formatHexStr(int width, String hexStr) {
        if (hexStr.length() >= width) {
            return hexStr.substring(hexStr.length() - width);
        }//w  w  w  .j  a  v  a 2  s. c  o  m
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < width - hexStr.length(); i++) {
            sb.append("0");
        }
        sb.append(hexStr);
        return sb.toString();
    }
}

Related

  1. formatHex(int value, int width)
  2. formatHex(Integer input)
  3. formatHexBytes(byte[] raw)
  4. formatHexInt(final StringBuilder dst, final int p, int w)
  5. formatHexReversed(String original, int length)
  6. formatHexString(final String input, final int charsPerLine)
  7. formatHexToString(byte[] bytes)
  8. formatInHex(byte[] bySrc, int nLineLen)
  9. formatText(String value, boolean showAsHexFlag)