首页 > 解决方案 > 带有文件参数的Spring批量写入异常

问题描述

我想将异常写入与项目编写器相同的文件中,但不起作用

// MyLitner

public static class MySkipListener implements SkipListener<CSCiviqueDTO, CSCiviqueDTO> {

private BufferedWriter bw = null;

  public MySkipListener(File file) throws IOException {
     bw= new BufferedWriter(new FileWriter(file, true));
  }

    @Override
    public void onSkipInRead(Throwable throwable) {
        if (throwable instanceof FlatFileParseException) {
            FlatFileParseException flatFileParseException = (FlatFileParseException) throwable;
            System.out.println("onSkipInRead =========> :");
            try {
                bw.write(flatFileParseException.getInput() + "; Step Vérifiez les colonnes !!");
                bw.newLine();
                bw.flush();
                // fileWriter.close();
            } catch (IOException e) {
                System.err.println("Unable to write skipped line to error file");
            }
        }
    }

标签: spring-batch

解决方案


推荐阅读