Here you can find the source of arrayToSVMLightString(int[] array)
public static String arrayToSVMLightString(int[] array)
//package com.java2s; //License from project: Apache License public class Main { public static String arrayToSVMLightString(int[] array) { StringBuilder str = new StringBuilder(); for (int i = 0; i < array.length; i++) { if (array[i] > 0) { str.append(i).append(":").append(array[i]).append(" "); }/*from w w w .j av a2 s .c o m*/ } return str.toString(); } public static String arrayToSVMLightString(float[] array) { StringBuilder str = new StringBuilder(); for (int i = 0; i < array.length; i++) { if (array[i] > 0) { str.append(i).append(":").append(array[i]).append(" "); } } return str.toString(); } public static String arrayToSVMLightString(double[] array) { StringBuilder str = new StringBuilder(); for (int i = 0; i < array.length; i++) { if (array[i] > 0) { str.append(i).append(":").append(array[i]).append(" "); } } return str.toString(); } }