List of usage examples for java.lang StringBuilder append
@Override public StringBuilder append(double d)
From source file:Main.java
public static ByteBuffer getDataBuffer() { String lineSeparator = System.getProperty("line.separator"); StringBuilder sb = new StringBuilder(); sb.append("test"); sb.append(lineSeparator);/* w ww . j av a 2 s. c om*/ sb.append("test"); sb.append(lineSeparator); String str = sb.toString(); Charset cs = Charset.forName("UTF-8"); ByteBuffer bb = ByteBuffer.wrap(str.getBytes(cs)); return bb; }
From source file:Main.java
public static String randomDecimalString(int ndigits) { StringBuilder result = new StringBuilder(); for (int i = 0; i < ndigits; i++) { result.append(randomDecimalDigit()); }/*from w w w .j ava2 s. c om*/ return result.toString(); }
From source file:Main.java
public static String generateMultiContentType(final String boundary, final String charset) { StringBuilder buffer = new StringBuilder(); buffer.append("multipart/form-data; boundary="); buffer.append(boundary);/*from w w w .j a v a 2 s .co m*/ if (charset != null) { buffer.append("; charset="); buffer.append(charset); } return buffer.toString(); }
From source file:Main.java
public static void writeData(SeekableByteChannel seekableChannel, Charset cs) throws IOException { String separator = System.getProperty("line.separator"); StringBuilder sb = new StringBuilder(); sb.append("test"); sb.append(separator);// w w w. j a v a 2s .c o m sb.append("test2"); sb.append(separator); CharBuffer charBuffer = CharBuffer.wrap(sb); ByteBuffer byteBuffer = cs.encode(charBuffer); seekableChannel.write(byteBuffer); }
From source file:Main.java
public static String getMonthStringFromDate(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);/* ww w . ja v a 2 s.c om*/ StringBuilder sb = new StringBuilder(); sb.append(calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.US)).append(", ") .append(calendar.get(Calendar.YEAR)); return sb.toString(); }
From source file:Main.java
public static String getExternalDir() { final StringBuilder sb = new StringBuilder(); sb.append(Environment.getExternalStorageDirectory().getAbsolutePath()); sb.append("/xdrip"); final String dir = sb.toString(); return dir;/*from w w w .j av a 2s .com*/ }
From source file:Main.java
/** * Build a tag <code><tagName/></code>. * // w w w . j a v a 2 s .co m * @param pTagName * name of the tag. * @return requested tag. */ public static String startEndTag(String pTagName) { StringBuilder tag = new StringBuilder(); tag.append(TAG_START_LOW); tag.append(pTagName); tag.append(TAG_START_SLASH_SUP); return tag.toString(); }
From source file:Main.java
private static String toHexString(byte[] b, int len) { StringBuilder s = new StringBuilder(); s.append("\""); for (int i = 0; i < len; i++) { if (i > 0) { s.append(" "); }/* w w w . j av a2 s . c o m*/ s.append(String.format("%02x", b[i] & 0xFF)); } s.append("\""); return s.toString(); }
From source file:Main.java
private static byte[] getFileParameters(String fileName, String contentType, String charset) throws UnsupportedEncodingException { StringBuilder sb = new StringBuilder(); sb.append("Content-Disposition:form-data;name=\""); sb.append("upload"); sb.append("\";filename=\""); sb.append(fileName);/*from w ww .j a va 2s.c om*/ sb.append("\"\r\nContent-Type:"); sb.append(contentType); sb.append("\r\n\r\n"); return sb.toString().getBytes(charset); }
From source file:Main.java
public static String getThemeAlphaColor(int alpha) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("#"); stringBuilder.append(String.format("%02x", alpha * 255 / 100)); stringBuilder.append("12B7F5"); return stringBuilder.toString(); }