package com.kamco.cd.kamcoback.common.utils.zip;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class TextFileProcessor implements ZipEntryProcessor {

  @Override
  public boolean supports(String fileName) {
    return fileName.toLowerCase().endsWith(".txt");
  }

  @Override
  public void process(String fileName, InputStream is) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(is));
    String line;
    while ((line = br.readLine()) != null) {
      log.info(line); // TODO : 추후 txt 파일 읽어서 작업할 때 정의하기
    }
  }
}
