Java array join long[] array to String
//package com.demo2s; public class Main { public static void main(String[] argv) throws Exception { long[] tokens = new long[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 }; String delimiter = ""; System.out.println(joinLongs(tokens, delimiter)); }//from w ww .java 2 s . co m /** * Concatenates the given long[] array into one String, inserting a delimiter * between each pair of elements. */ public static String joinLongs(long[] tokens, String delimiter) { if (tokens == null) return ""; StringBuilder result = new StringBuilder(); for (int i = 0; i < tokens.length; i++) { if (i > 0 && delimiter != null) { result.append(delimiter); } result.append(String.valueOf(tokens[i])); } return result.toString(); } }