List of usage examples for java.lang StringBuilder append
@Override public StringBuilder append(double d)
From source file:Main.java
public static UUID parseUUID(String uuidValue) { try {//from w w w .ja va 2 s.c o m return UUID.fromString(uuidValue); } catch (IllegalArgumentException x) { StringBuilder buf = new StringBuilder(36); buf.append(uuidValue); while (buf.length() < 32) { buf.insert(0, '0'); } buf.insert(8, '-'); buf.insert(13, '-'); buf.insert(18, '-'); buf.insert(23, '-'); return UUID.fromString(buf.toString()); } }
From source file:Main.java
public static String multiStr(int count, String str) { if (null == str || str.equals("") || count <= 0) { return ""; }/*from w w w . j av a 2 s . c om*/ StringBuilder sb = new StringBuilder(); for (int i = 0; i < count; i++) sb.append(str); return sb.toString(); }
From source file:Main.java
public static ThreadFactory createFactory(final String threadName) { return new ThreadFactory() { int sequence; public Thread newThread(Runnable r) { sequence += 1;/*from w w w. j a v a 2 s . c o m*/ StringBuilder sb = new StringBuilder(); sb.append('[').append(Thread.currentThread().getThreadGroup().getName()).append("] "); sb.append(threadName).append(" - ").append(sequence); return new Thread(r, sb.toString()); } }; }
From source file:Main.java
public static String toHexString(byte[] data) { if (data == null || data.length == 0) { return ""; }/*ww w.j a va2 s.c o m*/ 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 void appendTextElement(StringBuilder sb, String tagName, String value) { appendTagPre(sb, tagName);/* w ww.j ava 2 s . co m*/ sb.append(value); appendTagPost(sb, tagName); }
From source file:Main.java
public static String leftPad(String source, int size, String s) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < size; i++) builder.append(s); builder.append(source);/*from w w w . j a va 2s.c o m*/ return builder.toString(); }
From source file:Main.java
public static String toString(Collection<? extends Object> collection, String separator) { StringBuilder sb = new StringBuilder(); for (Object obj : collection) { sb.append(obj).append(separator); }//w ww . j av a 2 s .co m return sb.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;// w ww.j a va2 s . c om while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } is.close(); return sb.toString(); }
From source file:Main.java
public static String getRandomString(int length) { String retVal = "1234567890"; StringBuilder sb = new StringBuilder(); for (int i = 0; i < length; i++) sb.append(retVal.charAt(random.nextInt(retVal.length()))); return sb.toString(); }
From source file:Main.java
private static String analyzeMethodName(String fieldName, String methodType) { StringBuilder getName = new StringBuilder(methodType); return getName.append(String.valueOf(fieldName.charAt(0)).toUpperCase() + fieldName.substring(1)) .toString();/*from w ww . ja v a2s . c o m*/ }