티스토리 뷰

file.my=C:\\file\\

 

@Value("${file.my}")
private String path; 

 

@Scheduled(cron="${batch.time4}")
public void aBatch() throws Exception{

System.out.println("My Batch Start");

try {

SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd");
Calendar cal=Calendar.getInstance();
cal.add(cal.DATE, -1);

String file1="";
String date=sdf.format(cal.getTime());
file1="a_"+date+".txt";

File myFile = new File(path+file1); //config.properties
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(myFile),"EUC-KR"));//문자인코딩
String line = null;

int resultCnt=0;

while ((line = reader.readLine()) != null  ) {
System.out.println(line);


if(line != null){
String[] arr = line.split("-");

if(arr.length > 5){

HashMap map = new HashMap();

String empNo=arr[8];

if(empNo == null || "".equals(empNo)){
continue;
}
map.put("EMP_NO" ,empNo);
map.put("WORK_DATE" ,arr[0]);
map.put("WORK_TIME" ,arr[1]);

cDao.insertA(map);

}
}
resultCnt++;
}

} catch (Exception e) {

}

}

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/06   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함