Example usage for java.lang StringBuffer append

List of usage examples for java.lang StringBuffer append

Introduction

In this page you can find the example usage for java.lang StringBuffer append.

Prototype

@Override
    public synchronized StringBuffer append(double d) 

Source Link

Usage

From source file:Main.java

public static String SHA1(String input) throws NoSuchAlgorithmException {
    MessageDigest mDigest = MessageDigest.getInstance("SHA1");
    byte[] result = mDigest.digest(input.getBytes());
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < result.length; i++) {
        sb.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1));
    }//from   w  w w.j  av a2  s  .  c  o m

    return sb.toString();
}

From source file:Main.java

public static String Bcd2Str_0(byte[] bytes) {
    StringBuffer temp = new StringBuffer(bytes.length * 2);

    for (int i = 0; i < bytes.length; i++) {
        temp.append((byte) ((bytes[i] & 0xf0) >>> 4));
        temp.append((byte) (bytes[i] & 0x0f));
    }//from w  w  w  . j a  v  a  2s .c o m

    return temp.toString().substring(0, temp.toString().length() - 1);
}

From source file:Main.java

public static String MapToUrl(Map<?, ?> data) {
    StringBuffer queryString = new StringBuffer();
    for (Map.Entry<?, ?> pair : data.entrySet()) {
        queryString.append(pair.getKey() + "=");
        queryString.append(pair.getValue() + "&");
    }//from   ww  w. java  2s  .  c  o m
    if (queryString.length() > 0) {
        queryString.deleteCharAt(queryString.length() - 1);
    }
    return queryString.toString();
}

From source file:Main.java

public static String getColumnId(int column) {
    Stack<Character> digits = new Stack<Character>();
    int dividant = column;
    while (dividant > 26) {
        int remain = dividant % 26;
        dividant = dividant / 26;//  www  .  j  a  v a2  s  .  com
        if (remain == 0) {
            remain = 26;
            dividant--;
        }
        digits.push((char) ('A' + remain - 1));
    }
    digits.push((char) ('A' + dividant - 1));
    StringBuffer buffer = new StringBuffer();
    while (!digits.empty()) {
        buffer.append(digits.pop());
    }
    String columnId = buffer.toString();
    return columnId;
}

From source file:Main.java

public static String getUserAgent() {
    StringBuffer sb = new StringBuffer("Mapbox Android SDK");

    if (getVersionNumber() != null) {
        sb.append("/");
        sb.append(getVersionNumber());//  w  ww  .  j av  a 2  s . c o m
    }

    return sb.toString();
}

From source file:Main.java

private static String threadLockedSynchronizers(ThreadInfo threadInfo) {
    final String NO_SYNCH_INFO = "no locked synchronizers information available\n";
    if (null == threadInfo) {
        return NO_SYNCH_INFO;
    }/*from   w w  w .j a va  2s.c o m*/
    try {
        final LockInfo[] lockInfos = threadInfo.getLockedSynchronizers();
        if (lockInfos.length > 0) {
            final StringBuffer lockedSynchBuff = new StringBuffer();
            lockedSynchBuff.append("\nLocked Synchronizers: \n");
            for (final LockInfo lockInfo : lockInfos) {
                lockedSynchBuff.append(lockInfo.getClassName()).append(" <")
                        .append(lockInfo.getIdentityHashCode()).append("> \n");
            }
            return lockedSynchBuff.append("\n").toString();
        } else {
            return "";
        }
    } catch (final Exception e) {
        return NO_SYNCH_INFO;
    }
}

From source file:Main.java

/**
 * Concatenates the elements of the iterator to one string.
 * If the iterator has no elements an empty string is returned.
 *
 * @param iterator iterator//from w  ww.j  a  v  a2s . c om
 * @param start start string
 * @param delimiter delimiter between the elements
 * @param end end string
 * @return concatenation
 */
public static String join(Iterator iterator, String start, String delimiter, String end) {
    if (iterator.hasNext()) {
        StringBuffer s = new StringBuffer();

        s.append(start);
        s.append(iterator.next());

        while (iterator.hasNext()) {
            s.append(delimiter);
            s.append(iterator.next());
        }

        s.append(end);

        return s.toString();
    } else {
        return "";
    }
}

From source file:Main.java

public static String toString(Reader reader) throws IOException {
    int charValue;
    StringBuffer sb = new StringBuffer(1024);
    while ((charValue = reader.read()) != -1) {
        sb.append((char) charValue);
    }/* w ww .  jav  a2s  .co  m*/
    return sb.toString();
}

From source file:Main.java

private static void logInConsole(ArrayList<Integer> timePoints) {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < timePoints.size(); i++) {
        sb.append(timePoints.get(i)).append(" ");
    }//from w w  w  . j a va 2  s .c  om
    Log.d(TAG, sb.toString());
}

From source file:Main.java

public static String maskString(String str) {
    StringBuffer buf = new StringBuffer(str.length());
    for (int i = 0; i < str.length(); i++) {
        buf.append("*");
    }//from   w  ww.ja  v  a  2  s.co  m
    return buf.toString();
}