List of usage examples for java.lang StringBuilder append
@Override public StringBuilder append(double d)
From source file:Main.java
public static String optPath(String soPath, String optdir) { String str;/*from www. j av a 2 s . co m*/ if ((soPath == null) || (optdir == null)) { str = null; } StringBuilder sb = new StringBuilder(80); sb.append(optdir); if (!optdir.endsWith("/")) sb.append("/"); int i = soPath.lastIndexOf("/"); if (i >= 0) soPath = soPath.substring(i + 1); int j = soPath.lastIndexOf("."); if (j < 0) { sb.append(soPath); } else { sb.append(soPath, 0, j); } sb.append(".dex"); str = sb.toString(); return str; }
From source file:Main.java
/** * Gets the opening (left) string for a plural statement. * @param varName The plural var name.//w w w .j ava 2s.c o m * @param offset The offset. * @return the ICU syntax string for the plural opening string. */ public static String getPluralOpenString(String varName, int offset) { StringBuilder openingPartSb = new StringBuilder(); openingPartSb.append('{').append(varName).append(",plural,"); if (offset != 0) { openingPartSb.append("offset:").append(offset).append(' '); } return openingPartSb.toString(); }
From source file:Main.java
public static String getDeviceInfo(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); StringBuilder sb = new StringBuilder(); sb.append("\nDeviceId(IMEI) = " + tm.getDeviceId()); sb.append("\nDeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion()); sb.append("\nLine1Number = " + tm.getLine1Number()); sb.append("\nNetworkCountryIso = " + tm.getNetworkCountryIso()); sb.append("\nNetworkOperator = " + tm.getNetworkOperator()); sb.append("\nNetworkOperatorName = " + tm.getNetworkOperatorName()); sb.append("\nNetworkType = " + tm.getNetworkType()); sb.append("\nPhoneType = " + tm.getPhoneType()); sb.append("\nSimCountryIso = " + tm.getSimCountryIso()); sb.append("\nSimOperator = " + tm.getSimOperator()); sb.append("\nSimOperatorName = " + tm.getSimOperatorName()); sb.append("\nSimSerialNumber = " + tm.getSimSerialNumber()); sb.append("\nSimState = " + tm.getSimState()); sb.append("\nSubscriberId(IMSI) = " + tm.getSubscriberId()); sb.append("\nVoiceMailNumber = " + tm.getVoiceMailNumber()); return sb.toString(); }
From source file:Main.java
public static String bytes2Hex(byte[] bytes) { StringBuilder sb = new StringBuilder(); for (byte b : bytes) { sb.append(String.format("%02X ", b)); }/*from ww w . j a va 2s . co m*/ return sb.toString(); }
From source file:Main.java
/** * Joins the elements in an input collection using a given separator. * * @param <A> Key type/*from ww w. j a v a 2 s . c o m*/ * @param collection Input collection * @param separator Separator * @return {@code String} representation of the input {@code collection} */ public static <A> String join(Collection<A> collection, String separator) { if (collection.isEmpty()) return ""; Iterator<A> it = collection.iterator(); StringBuilder out = new StringBuilder(); out.append(it.next()); while (it.hasNext()) out.append(separator).append(it.next()); return out.toString(); }
From source file:Main.java
private static String getTempLocation() { String tmpdir = System.getProperty("java.io.tmpdir"); StringBuilder sb = new StringBuilder(); sb.append(tmpdir); if (!tmpdir.endsWith(File.separator)) sb.append(File.separator); sb.append("TempAzure"); sb.append(File.separator);//from w ww .j a va 2 s. c om sb.append("MobileServiceTemplate"); sb.append(File.separator); return sb.toString(); }
From source file:Main.java
/** * Appends the specified path token to the provided buffer followed by the * position specification of the target node in its siblings list (if * needed)./* ww w . j av a 2 s .co m*/ * * @param node * the target node for the XPath expression. * @param siblings * the siblings of the target node. * @param pathToken * the path token identifying the target node. * @param buffer * the buffer to which appending the XPath sub-expression or * <code>null</code> if the method shall allocate a new buffer. * @return the XPath sub-expression to select the target node among its * siblings. */ private static StringBuilder getPositionPath(Object node, List<?> siblings, String pathToken, StringBuilder buffer) { buffer.append(pathToken); if (siblings != null) { int position = 0; final Iterator<?> i = siblings.iterator(); while (i.hasNext()) { position++; if (i.next() == node) break; } if (position > 1 || i.hasNext()) { // the item is not at the first location, ot there are more // locations. in other words, indexing is required. buffer.append('[').append(position).append(']'); } } return buffer; }
From source file:almira.sample.client.ListCatapults.java
static void executeQuery(ObjectQueryService<Catapult, Long> service) { long startTime = System.nanoTime(); List<Catapult> catapults = service.findAll(START_INDEX, FETCH_SIZE); long timeDifference = System.nanoTime() - startTime; StringBuilder sb = new StringBuilder(); sb.append("\nRequesting "); sb.append(catapults.size());/*from w ww . java 2 s . c o m*/ sb.append(" catapults took: "); sb.append(timeDifference / NANOS_IN_SEC); sb.append(" ms"); printMessage(sb.toString()); for (Catapult c : catapults) { printMessage(c.toString()); } }
From source file:com.microsoft.azure.shortcuts.resources.samples.LoadBalancersSample.java
private static void printLB(LoadBalancer lb) throws Exception { StringBuilder output = new StringBuilder(); output.append(String.format("Load Balancer ID: %s\n", lb.id())) .append(String.format("\tName: %s\n", lb.name())) .append(String.format("\tGroup: %s\n", lb.resourceGroup())); System.out.println(output.toString()); }
From source file:Main.java
private static final String ten2Any(long num, int base) { StringBuilder sb = new StringBuilder(7); while (num != 0) { sb.append(str62.charAt((int) (num % base))); num /= base;//w ww . ja va2 s.c o m } return sb.reverse().toString(); }