1

I am currently using SuperCSV (v 2.4.0) for exporting data. I am stuck in with the below problem.

※My problem: - My CSV header has 9 columns -There is a line which missing a comma dilimiter (,) between two fields, so that line become a 8-columns line - The messing line is occur randomly, not exact the same line for every exporting.

※Here my code: ① CSV Writing function // obmitting

    stmt = con.prepareStatement(sql);
    rs = stmt.executeQuery();

    // obmitting
    // ............

    fos = new FileOutputStream(folderPath + "/" + FILE_NAME);
    osw = new OutputStreamWriter(fos, "EUC-JP");
    beanWriter = new CsvBeanWriter(osw, csvType);
    beanWriter.writeHeader(this.CSV_HEADER);

    while(rs.next()) {
        AttachmentsBean bean = new AttachmentsBean();
        bean.setCompDispId(pMng.getCompDispId());
        bean.setFileId(rs.getString(1));
        bean.setDocumentId(rs.getString(2));
        bean.setFileName(rs.getString(3));
        bean.setDiscription(rs.getString(4));
        bean.setFileSize(rs.getString(5));
        bean.setFilePath(rs.getString(6));
        bean.setMimetype(rs.getString(7));
        bean.setFileOrder(rs.getString(8));
        progressCount++;
        //出力
        beanWriter.write(bean, this.CSV_HEADER);

    }

    //CSV出力終了
    IOUtils.closeQuietly(beanWriter);
    IOUtils.closeQuietly(osw);
    IOUtils.closeQuietly(fos);

    //文字変換
    CommonUtil.convertFile(folderPath, folderPath +"/"+ FILE_NAME);

② ConvertFile helper function this function is convert special character from EUC to UTF-8

※My question is, is my problem caused by superCSV bug ? can anyone help to figure out the cause ? because i have read from the below discussion, maybe not only i meet the mess up csv problem, but some one did too. Messed up CSV leads to Exception

Community
  • 1
  • 1
Vô Tình
  • 11
  • 1

0 Answers0