List of usage examples for java.lang StringBuffer toString
@Override @HotSpotIntrinsicCandidate public synchronized String toString()
From source file:com.thoughtworks.go.config.ResourceConfigs.java
private static String join(List<String> c, String join) { StringBuffer sb = new StringBuffer(); for (String s : c) { sb.append(s);//from ww w . j ava 2s. co m sb.append(join); } return sb.toString(); }
From source file:Main.java
public static String byte2Hex(byte[] bytes) { StringBuffer sb = new StringBuffer(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { sb.append(HEX_ARRAY[(bytes[i] & 0xf0) >>> 4]); sb.append(HEX_ARRAY[bytes[i] & 0x0f]); }//from w w w . java2s .c o m return sb.toString(); }
From source file:StringUtils.java
/** * Generates a hexadecimal string from an array of bytes. For * example, if the array contains { 0x01, 0x02, 0x3E }, the resulting * string will be "01023E".//from ww w . j a va 2 s . c o m * * @param bytes A Byte array * @return A String representation * @since 2.3.87 */ public static String toHexString(byte[] bytes) { StringBuffer sb = new StringBuffer(bytes.length * 2); for (int i = 0; i < bytes.length; i++) { sb.append(toHex(bytes[i] >> 4)); sb.append(toHex(bytes[i])); } return sb.toString(); }
From source file:MainClass.java
public static String remainingElements(int low, int high) { StringBuffer temporary = new StringBuffer(); for (int i = 0; i < low; i++) temporary.append(" "); for (int i = low; i <= high; i++) temporary.append(data[i] + " "); temporary.append("\n"); return temporary.toString(); }
From source file:Main.java
public static String toHexString(byte bytes[]) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < bytes.length; ++i) { buf.append(Integer.toHexString(0x0100 + (bytes[i] & 0x00FF)).substring(1)); }//from w ww .j a v a 2 s. c o m return buf.toString(); }
From source file:Main.java
/** Encodes datas using base64 encoding. * @param abyte0 data for encoding/*from w w w . jav a 2s.c o m*/ * @return encoded string */ public static String encode(final byte abyte0[]) { final StringBuffer stringbuffer = new StringBuffer(); for (int i = 0; i < abyte0.length; i += 3) stringbuffer.append(encodeBlock(abyte0, i)); return stringbuffer.toString(); }
From source file:Main.java
public static String getHash(String input) { if (input == null || input.equals("") || input.isEmpty()) { return ""; }/*from w ww . j a v a2s . c o m*/ try { MessageDigest md = MessageDigest.getInstance("SHA-256"); byte[] messageDigest = md.digest(input.getBytes()); StringBuffer sb = new StringBuffer(); for (int i = 0; i < messageDigest.length; i++) { sb.append(Integer.toString((messageDigest[i] & 0xff) + 0x100, 16).substring(1)); } return sb.toString(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); return ""; } }
From source file:com.newatlanta.appengine.vfs.provider.GaeFileNameParser.java
public static String getRootPath(FileName baseName) throws FileSystemException { FileName rootName = baseName.getRoot(); if (rootName instanceof GaeFileName) { return ((GaeFileName) rootName).getRootPath(); } else {// ww w . j a va 2 s. c om StringBuffer rootPath = new StringBuffer(); UriParser.extractScheme(baseName.getURI(), rootPath); UriParser.normalisePath(rootPath); return rootPath.toString().intern(); } }
From source file:Main.java
public static String getRandomString(int length) { if (length <= 0) return null; StringBuffer sb = new StringBuffer(); Random r = new Random(); int range = RANDOM_CHARS.length(); for (int i = 0; i < length; i++) { sb.append(RANDOM_CHARS.charAt(r.nextInt(range))); }// w ww .j a v a 2s. c o m return sb.toString(); }
From source file:Main.java
public static final String decodeInterfereWord(String src) { StringBuffer sb = new StringBuffer(); for (int index = 0, size = src.length(); index < size; index++) { if (index % 2 == 0) { continue; }/*from w w w.j av a 2s . co m*/ sb.append(src.charAt(index)); } return sb.toString(); }