728x90
반응형
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
/**
* Mission1 깜짝과제 1번
* property.html 파일을 만드는 코드 작성하기
*
* @author : 이희영
*/
public class Property {
/**
* 파일 생성
*/
public static void generateFile() {
try {
File file = new File("property.html");
BufferedWriter bw =new BufferedWriter(new FileWriter(file));
// HTML Head
bw.write("<html>\n <head>\n <meta charset=\"UTF-8\" />\n");
bw.write("<style>\n table { border-collapse: collapse; width: 100%; } \n th, td { border : solid 1px #000; }\n </style>\n");
bw.write("</head>\n");
// HTML body
bw.write("<body>\n <h1>자바 환경정보</h1>\n");
bw.write("<table>\n <tr>\n <th>키</th>\n <th>값</th>\n </tr>\n");
for (Object k : System.getProperties().keySet()) {
String key = k.toString();
String value = System.getProperty(key);
bw.write("<tr>\n <td>" + key + "</td>\n <td>" + value + "</td>\n </tr>\n");
}
bw.write("</table>\n </body>\n </html>");
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
generateFile();
}
}
728x90
반응형
'📌Zero-base' 카테고리의 다른 글
페이지네비게이션 구현 제로베이스 백엔드 스쿨 깜짝과제 3번 (0) | 2024.05.13 |
---|---|
가장 가까운 좌표 출력 프로그램 제로베이스 백엔드 스쿨 깜짝과제 2번 (0) | 2024.05.13 |
백엔드 신입 개발자가 쌓아야 하는 역량은? 제로베이스 백엔드스쿨 (0) | 2024.05.01 |
Java 람다식, 스트림 (0) | 2024.04.29 |
코딩테스트 힌트 문제 풀기 2 (프로그래머스, 백준) 자바 (0) | 2024.04.29 |