티스토리 뷰
public class FileWriterTest{
public static void main(String[] args){
System.out.println("Start");
String txt="테스트";
String path="D:\\batch\\";
File f=new File(path);
String pathFile="";
String fileName="text";
String ext=".txt";
SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd");
Date date = new Date();
String yyyyMMdd=sdf.format(date);
pathFile=fileName+"_"+yyyyMMdd+ext;
Calendar cal =new GregorialCalendar();
cal.add(Calendar.DATE, -1_;
String yest=sdf.format(cal.getTime(););
pathFile=path+pathFile;
try{
if(!f.isDirectory()){
f.mkdir();
}
PrinterWriter pw = new PrintWriter(new BufferedWriter (new BufferedWriter(new FileWriter(pathFile))));
pw.println(txt);
pw.println(txt);
pw.flush();
pw.close();
}catch(Exception e){
e.printStackTrace();
}
System.out.println("End");
}
}
public static void main(String[] args){
System.out.println("Start");
String txt="테스트";
String path="D:\\batch\\";
File f=new File(path);
String pathFile="";
String fileName="text";
String ext=".txt";
SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd");
Date date = new Date();
String yyyyMMdd=sdf.format(date);
pathFile=fileName+"_"+yyyyMMdd+ext;
Calendar cal =new GregorialCalendar();
cal.add(Calendar.DATE, -1_;
String yest=sdf.format(cal.getTime(););
pathFile=path+pathFile;
try{
if(!f.isDirectory()){
f.mkdir();
}
PrinterWriter pw = new PrintWriter(new BufferedWriter (new BufferedWriter(new FileWriter(pathFile))));
pw.println(txt);
pw.println(txt);
pw.flush();
pw.close();
}catch(Exception e){
e.printStackTrace();
}
System.out.println("End");
}
}
'자바(Java)' 카테고리의 다른 글
java – 날짜 문자열에서 시간 추출 (0) | 2019.08.06 |
---|---|
자바 파일 읽기 및 이동 (0) | 2019.08.05 |
자바 파일 쓰기 (0) | 2019.08.05 |
jsp에서 config.properties 파일 읽는 방법 (0) | 2019.08.02 |
자바 일정 시간 후 전체화면 이미지 모니터 꽉 차게 (0) | 2019.07.31 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- ocajp
- esql
- XE
- KG
- 파이썬
- 스크래핑
- php
- 자바 smtp
- 플러터
- xe addon
- C언어
- XE3
- 파싱
- JDBC
- C
- 오라클
- 인포믹스
- xe애드온
- 프로씨
- proc
- MySQL
- Python
- 문자열
- ocjap
- 자바
- EC
- 이클립스
- 포인터
- webix
- 라이믹스 모듈
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함