List of usage examples for java.lang StringBuilder toString
@Override
@HotSpotIntrinsicCandidate
public String toString()
From source file:Main.java
public static String getYearStringFromDate(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);/*ww w . j a v a2 s . co m*/ StringBuilder sb = new StringBuilder("Year ").append(calendar.get(Calendar.YEAR)); return sb.toString(); }
From source file:Main.java
static String init() { StringBuilder sb = new StringBuilder(); sb.appendCodePoint(CODE_POINT); return sb.toString(); }
From source file:Main.java
static public String getViewHierarchy(View v) { StringBuilder s = new StringBuilder(); getViewHierarchy(v, s, 0);//from w w w. j av a 2 s .co m return s.toString(); }
From source file:Main.java
/** * Converts a file to a string/*from w w w . ja v a2s .c o m*/ * @param f The file * @return The string * @throws IOException Thrown in any IOException occurs */ public static String fileToString(File f) throws IOException { ArrayList<String> list = new ArrayList<>(Files.readAllLines(f.toPath())); StringBuilder builder = new StringBuilder(); list.forEach(builder::append); return builder.toString(); }
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);/*from w ww.j av a2 s. co m*/ 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 printDom(Node n, String prefix) { StringBuilder sb = new StringBuilder(); printDom(n, prefix, sb);/* ww w . ja va2 s . c o m*/ return sb.toString(); }
From source file:Main.java
public static String printStackTrace(StackTraceElement[] stack) { StringBuilder output = new StringBuilder(1000); appendThreadStackTrace(output, stack); return output.toString(); }
From source file:Main.java
public static String limitMessage(String str, int limit) { if (str.length() <= limit) { return str; } else {// w w w . j ava 2s .c o m StringBuilder sb = new StringBuilder(str.substring(0, limit)); sb.append("..."); return sb.toString(); } }
From source file:Main.java
public static String getInnerText(Element elt) { StringBuilder sb = new StringBuilder(); getInnerText(sb, elt, " "); return sb.toString(); }
From source file:Main.java
public static void appendText(JTextComponent jcomponent, String str) { StringBuilder stringBuilder = new StringBuilder(jcomponent.getText()).append("\n").append(str); jcomponent.setText(stringBuilder.toString()); }