Spring批处理写异常与文件参数

时间:2019-03-18 16:11:05

标签: spring-batch

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

// 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");
            }
        }
    }

0 个答案:

没有答案