List of usage examples for java.lang Integer toString
@HotSpotIntrinsicCandidate public static String toString(int i)
From source file:Main.java
public static void contentIntSet(Document doc, Element base, String name, int value, int defaultInt) { if (value != defaultInt) { addElementAndSetContent(doc, name, base, Integer.toString(value)); }//w w w . j av a 2 s . c om }
From source file:Main.java
/** * parse InetAddress/*from w ww .ja v a 2 s . c o m*/ * * @param inetAddrBytes * @return */ public static InetAddress parseInetAddr(byte[] inetAddrBytes, int offset, int count) { InetAddress inetAddress = null; StringBuilder sb = new StringBuilder(); for (int i = 0; i < count; i++) { sb.append(Integer.toString(inetAddrBytes[offset + i] & 0xff)); if (i != count - 1) { sb.append('.'); } } try { inetAddress = InetAddress.getByName(sb.toString()); } catch (UnknownHostException e) { e.printStackTrace(); } return inetAddress; }
From source file:Main.java
public static void addAttribute(Document document, Node node, String attName, int attValue) { addAttribute(document, node, attName, Integer.toString(attValue)); }
From source file:Main.java
/** * Write an int value into a byte array. * * @param value The value to write.//from w w w . j av a2 s . com * @param buf The byte array into which to write. * @param offset The offset into the buffer from which to write. * @param length The number of header bytes to write. * @return The number of bytes written to the buffer. */ public static int getIntegerBytes(int value, byte[] buf, int offset, int length) { int i; String tmp = Integer.toString(value); int c = tmp.length(); for (i = 0; i < length && i < c; i++) { buf[offset + i] = (byte) tmp.charAt(i); } while (i < length) { buf[offset + i] = (byte) ' '; i++; } return offset + length; }
From source file:Main.java
public static void writeInt(String name, int value, XMLStreamWriter writer) throws XMLStreamException { writer.writeAttribute(name, Integer.toString(value)); }
From source file:Main.java
private static String setZeroPad(int value) { if (value < 10) { return "0" + Integer.toString(value); }//from www. j a v a 2 s.co m return Integer.toString(value); }
From source file:Main.java
private static byte[] createByteArrayFromBitmap(Bitmap bitmap) { Log.e(LOG_TAG, "creating asset"); final ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteStream); Log.e(LOG_TAG, "length : " + Integer.toString(byteStream.toByteArray().length)); return byteStream.toByteArray(); }
From source file:Main.java
public static String formatTime(final long totalSeconds, final int timer) { if (timer == 0) { final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); sdf.setTimeZone(TimeZone.getTimeZone("GMT+0")); return sdf.format(new Date(totalSeconds * 1000)); } else {/*from ww w. ja v a 2s.c om*/ String seconds = Integer.toString((int) (totalSeconds % 60)); String minutes = Integer.toString((int) (totalSeconds / 60)); if (seconds.length() < 2) { seconds = "0" + seconds; } if (minutes.length() < 2) { minutes = "0" + minutes; } return minutes + ":" + seconds; } }
From source file:Main.java
/** * Append text value node.//w ww. j ava 2s.c o m * * @param baseNode * the base node * @param tagName * the tag name * @param tagValue * the tag value * @return the element */ public static Element appendTextValueNode(Node baseNode, String tagName, int tagValue) { return appendTextValueNode(baseNode, tagName, Integer.toString(tagValue)); }
From source file:Main.java
/** * //from w ww .j a v a 2 s . c o m */ protected static void decorateProperties(ThreadPoolExecutor executor, Properties properties) { if (executor != null) { if (properties != null) { properties.setProperty("thread-keep-alive-time", Long.toString(executor.getKeepAliveTime(TimeUnit.MILLISECONDS))); properties.setProperty("thread-pool-size-largest", Integer.toString(executor.getLargestPoolSize())); properties.setProperty("thread-pool-size-minimum", Integer.toString(executor.getCorePoolSize())); properties.setProperty("thread-pool-size-maximum", Integer.toString(executor.getMaximumPoolSize())); properties.setProperty("thread-pool-size", Integer.toString(executor.getPoolSize())); properties.setProperty("runnable-completed-count", Long.toString(executor.getCompletedTaskCount())); properties.setProperty("runnable-active-count", Integer.toString(executor.getActiveCount())); properties.setProperty("queue-size", Integer.toString(executor.getQueue().size())); properties.setProperty("queue-capacity-remaining", Integer.toString(executor.getQueue().remainingCapacity())); } } }