Example usage for java.lang StringBuilder toString

List of usage examples for java.lang StringBuilder toString

Introduction

In this page you can find the example usage for java.lang StringBuilder toString.

Prototype

@Override
    @HotSpotIntrinsicCandidate
    public String toString() 

Source Link

Usage

From source file:Main.java

/**
 * Generates a Repox Table Name from the collection identifier
 * /*from   ww w .j  a  va  2  s.c  o  m*/
 * @param menmonic
 * @return the Repox tablename
 */
public static String generateRepoxTableName(String menmonic) {
    StringBuilder sb = new StringBuilder();
    sb.append("repox_");
    sb.append(menmonic);
    sb.append("_record");
    return sb.toString();
}

From source file:Main.java

public static String join(Iterable<? extends CharSequence> s, String delimiter) {
    Iterator<? extends CharSequence> iter = s.iterator();
    if (!iter.hasNext())
        return "";
    StringBuilder buffer = new StringBuilder(iter.next());
    while (iter.hasNext())
        buffer.append(delimiter).append(iter.next());
    return buffer.toString();
}

From source file:Main.java

/**
 * devuelve el texto enmarcado en una etiqueta. Se supone que la etiqueta exite y tiene valor. Este m&eacute;todo funciona correctamente en el caso de que la etiqueta no tenga
 * multiplicidad. En el caso de que tuviera multiplicidad devolver&iacute;a &uacute;nicamente el prime contenido que se encuentre.
 * @param etiqueta etiqueta de la que queremos extraer su texto
 * @param documento: documento o subdocumento donde esta definida la etiqueta de la cual queremos extraer su texto
 * @return String Contenido de la etiqueta. En el caso de que la etiqueta no existiera devuelve <code>null</code>
 *//*from  w  w  w  .  j  a  v  a 2s.c  o  m*/
public static String dameTextoDeLaEtiquetaSinComprobaciones(String etiqueta, String documento) {
    StringBuilder sb = new StringBuilder("<");
    sb.append(etiqueta).append(">");
    int posEtiquetaApertura = documento.indexOf(sb.toString());
    sb = new StringBuilder("</");
    sb.append(etiqueta).append(">");
    int posEtiquetaCierre = documento.indexOf(sb.toString());
    return documento.substring(posEtiquetaApertura + etiqueta.length() + 2, posEtiquetaCierre);

}

From source file:Main.java

public static String toHexString(byte[] data) {
    if (data == null || data.length == 0) {
        return "";
    }/*from   w ww.j a  v  a 2 s  . com*/

    StringBuilder result = new StringBuilder();

    for (byte b : data) {
        result.append(String.format("0x%02X ", b));
    }
    return result.toString();
}

From source file:Main.java

public static String convertStreamToString(InputStream is) throws Exception {
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    StringBuilder sb = new StringBuilder();
    String line = null;//  www  . ja  v  a 2  s  .  co  m
    while ((line = reader.readLine()) != null) {
        sb.append(line + "\n");
    }
    is.close();
    return sb.toString();
}

From source file:Main.java

public static String toMacAddr(byte[] data) {
    if (data == null || data.length == 0) {
        return "";
    }//from   w w  w  .  j  a  v a2s.co  m

    StringBuilder result = new StringBuilder();

    for (byte b : data) {
        result.append(String.format("%02X:", b));
    }

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

From source file:Main.java

public static String toStringCollection(Collection list, String sep) {
    StringBuilder sb = new StringBuilder();
    for (Object s : list) {
        sb.append(s.toString());//w  w w .ja  v a 2s .  c o m
        sb.append(sep);
    }
    return sb.toString();
}

From source file:Main.java

public static String processKissMetricsQuery(String query, StringBuilder args) {
    if (args.length() > 0) {
        args.insert(0, URL_AND);//  w ww .  ja  v a 2s  . c o  m
    }
    args.insert(0, query);
    return args.toString();
}

From source file:Main.java

public static String toStringWithLength(byte[] b, int pos, int length) {
    StringBuilder str = new StringBuilder();

    for (int i = 0; i < length; i++) {
        str.append((char) b[pos + i]);
    }/*from  w  w  w  .  j av a  2  s  .  co m*/

    String ret = str.toString();
    return ret;
}

From source file:Main.java

public static String concat(Object... strings) {
    if (strings == null || strings.length == 0) {
        return null;
    }//from  w  w w . j  a va 2 s.co m
    StringBuilder builder = new StringBuilder();
    for (Object string : strings) {
        builder.append(string);
    }
    return builder.toString();
}