I have the following code. And the maps structure is 'Map<String, Long[]> Map' and it has the following values:
<com.service.a, 21221, 2121>
<com.service.b, 5454, 8787>
<com.service.c, 1227, 0>
public static void savetoFile(Map<String, Long[]> result, String filepath) throws IOException
{
FileWriter fw = new FileWriter(filepath,true);
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter pw = new PrintWriter(bw);
for (String name: result.keySet())
{
String key =name.toString();
Long[] value = result.get(name);
//System.out.println(key + " " + value);
pw.println(key+","+value);
}
pw.flush();
pw.close();
}
On running this function I get the following output:
{com.service.a=[Ljava.lang.Long;@135fbaa4, com.service.b=[Ljava.lang.Long;@4b67cf4d, com.service.c=[Ljava.lang.Long;@7ea987ac,}
How to get rid of this error? I have gone through certain link where they suggest to use toString() method but I'm not sure how to apply that within this function.
I want the above values to be stored into CSV file as :
com.service.a, 21221, 2121
com.service.b, 5454, 8787
com.service.c, 1227, 0