如何用JAVA来处理CSV文件呢?
读,写等等操作。
拜托各位大虾啦。

解决方案 »

  1.   

    简单点的写的例子,自己完善下,
    public class  WriteCsv{   
      private String dir;           //传个数据数俎和文件路径
          public void writeFile(String dir,String[][] array) throws Exception{ this.dir= dir;
    try {   
    File f=new File(dir);
        
            PrintWriter pw = new PrintWriter(new FileOutputStream(f));
    for (int i=0;i<array.length ;i++ )
    {
    for (int j=0;j<array[i].length ;j++ )
    {
    pw.print(array[i][j]); if(j<array[i].length-1)
    {
      pw.print(",");
    }
    else
        {
      pw.println();  
    }
    } }
    pw.close();
    } catch(IOException e) {
    ...
    }
    }}