-1
整数配列と文字列の書き込み方法CsvWriter
をcsv
形式で使用していますか?CSVWriter整数配列の場合
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Set;
import au.com.bytecode.opencsv.CSVReader;
import au.com.bytecode.opencsv.CSVWriter;
public class ArrayHash3
{
public static void main(String args[]) throws IOException
{
int[] WorkingDay = new int[13];
int i = 0;
String[] arrString = null;
int[] arrInt = null;
String[] Name = new String[13];
String file="C:\\Users\\Dhananjay Kumar\\Empdetail\\Detail.csv";
HashMap<String[],int[]> hashfunc=new HashMap<String[],int[]>();
CSVReader reader=new CSVReader(new FileReader(file));
String[] read;
while((read = reader.readNext()) !=null)
{
WorkingDay[i]=Integer.parseInt(read[2]);
Name[i]=read[0];
i++;
}
hashfunc.put(Name,WorkingDay);
hashfunc.get(Name);
Set<Entry<String[], int[]>> entrySet = hashfunc.entrySet();
for (Entry entry : entrySet)
{
arrInt = (int[]) entry.getValue();
arrString = (String[]) entry.getKey();
for(int j=0; j<arrInt.length; j++)
{
System.out.println(arrString[j]+":"+arrInt[j]);
}
}
String File1 = "C:\\Users\\Kumar\\Empdetail\\Detail6.csv";
CSVWriter fw = new CSVWriter(new FileWriter(File1, true));
fw.writeAll(arrString+","+arrInt);
fw.close();
}
}
私は、その私の必要性...使用する必要がありません仲間を見てください@ – UserAtHome
をsimas_chその後、出力がそのがsimas 26、dhananjay 56のようにする必要があり –
のようになりますどのように提供してください...その名前と値の両方を含める必要があることを意味します... – UserAtHome