List of usage examples for java.lang StringBuffer StringBuffer
public StringBuffer(CharSequence seq)
From source file:Main.java
public static String getClassFile(String name) { StringBuffer sb = new StringBuffer(name); name = name.replace('.', File.separatorChar) + ".class"; sb.append(File.separator + name); return sb.toString(); }
From source file:Main.java
public static String formathhmmss(String hhmmss) { if (null != hhmmss && hhmmss.length() == 6) { StringBuffer sb = new StringBuffer(hhmmss); sb.insert(2, ":"); sb.insert(5, ":"); return sb.toString(); }//w w w .ja v a 2s . c o m return ""; }
From source file:Main.java
private static String toHex(byte[] buf) { if (buf == null) { return ""; }// w w w. j a v a 2s. com StringBuffer result = new StringBuffer(2 * buf.length); for (byte aBuf : buf) { appendHex(result, aBuf); } return result.toString(); }
From source file:Main.java
public static String byteArr2HexStr(byte[] arrB) throws Exception { int iLen = arrB.length; StringBuffer sb = new StringBuffer(iLen * 2); for (int i = 0; i < iLen; ++i) { int intTmp; for (intTmp = arrB[i]; intTmp < 0; intTmp += 256) { ;/* w ww .ja v a 2s . co m*/ } if (intTmp < 16) { sb.append("0"); } sb.append(Integer.toString(intTmp, 16).toUpperCase()); } return sb.toString(); }
From source file:Main.java
public static String getNodePath(Node node) { StringBuffer sb = new StringBuffer(32); while (node != null) { sb.append(node.getNodeName());/*from w w w . j ava 2s . com*/ sb.append("/"); node = node.getParentNode(); } return sb.toString(); }
From source file:Main.java
public static String getMonthSelect(String selectName, String value, boolean hasBlank) { StringBuffer sb = new StringBuffer(""); sb.append("<select name=\"" + selectName + "\">"); if (hasBlank) { sb.append("<option value=\"\"></option>"); }//from w w w .j a v a2 s . co m for (int i = 1; i <= 12; i++) { if (!value.trim().equals("") && i == Integer.parseInt(value)) { sb.append("<option value=\"" + i + "\" selected>" + i + "</option>"); } else { sb.append("<option value=\"" + i + "\">" + i + "</option>"); } } sb.append("</select>"); return sb.toString(); }
From source file:Main.java
public static String getStringByMap(Map<String, Object> map) { StringBuffer sb = new StringBuffer(100); for (Map.Entry<String, Object> m : map.entrySet()) { String key = m.getKey();//from w w w. ja va2 s . c om Object value = m.getValue(); if (value != null) { String clsName = value.getClass().getName(); if (value.getClass().isArray()) sb.append("[").append(key).append(":").append("ARRAY").append(":") .append(toStringByArray((Object[]) value)).append("]"); else if ((("java.lang.String".equals(clsName)) || ("java.lang.Integer".equals(clsName)) || ("java.lang.Long".equals(clsName)) || ("java.lang.Boolean".equals(clsName)) || ("java.util.Date".equals(clsName))) && (!"".equals(value.toString()))) { sb.append("[").append(key).append(":").append(value.getClass().getName()).append(":") .append(esc(value.toString())).append("]"); } } } return sb.toString(); }
From source file:Main.java
public static String getFileLineMethod() { StackTraceElement traceElement = ((new Exception()).getStackTrace())[2]; StringBuffer toStringBuffer = new StringBuffer("[").append(traceElement.getFileName()).append(" | ") .append(traceElement.getLineNumber()).append(" | ").append(traceElement.getMethodName()) .append("]"); return toStringBuffer.toString(); }
From source file:Main.java
private static String remove(final String str, final String toRemove, final int location) { StringBuffer buffer = new StringBuffer(str); return buffer.replace(location, location + toRemove.length(), "").toString(); }
From source file:Util.java
public static String isoDateTimeToDate(String isoDate) { StringBuffer sb = new StringBuffer(isoDate); int maxlen;// w w w. ja va2s . co m if (isoDate.length() >= 10) { //2007-01-01 -> 20070101 //remove hyphens between year, month, and day sb.deleteCharAt(4); sb.deleteCharAt(6); maxlen = 8; //20070101T17:30:12 -> 20070101T173012 if (isoDate.length() >= 19) { maxlen = 15; //remove colons between hours, minutes, and seconds sb.deleteCharAt(11); sb.deleteCharAt(13); if (isoDate.indexOf("Z") >= 0) { sb.insert(15, 'Z'); ++maxlen; } } if (sb.length() > maxlen) sb.setLength(maxlen); } return sb.toString(); }