Created
August 12, 2023 18:32
-
-
Save rorrorome/90535ecfbbb085ec8265f87f02e5ff87 to your computer and use it in GitHub Desktop.
html 테이블구조
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * 제로베이스 백엔드 스쿨 15기 | |
| * 한새롬 | |
| * Mission 1 깜짝과제 1. 자바 환경 정보 html 테이블구조로 출력하기 | |
| * | |
| * 자바의 시스템 속성과 파일 저장 코드는 샘플 코드를 참조해 주세요. | |
| * 출력결과의 파일은 웹브라우저로 확인해서 정상적으로 표시되어야 합니다. | |
| * html파일을 작성할 때 테이블에 라인이 표시되도록 head 태그에 style태그 추가(샘플 코드 참조) | |
| */ | |
| import java.io.BufferedWriter; | |
| import java.io.File; | |
| import java.io.FileWriter; | |
| import java.io.IOException; | |
| public class Mini0101 { | |
| public static void main(String[] args) { | |
| StringBuffer sb = new StringBuffer(); | |
| sb.append("<head>\r\n" | |
| + " <meta charset=\"UTF-8\"/>\r\n" | |
| + " <style>\r\n" | |
| + " table {border-collapse: collapse; width: 100%;}\r\n" | |
| + " th, td {border:solid 1px #000;}\r\n" | |
| + " </style>\r\n" | |
| + "</head>\r\n" | |
| + "<body>\r\n" | |
| + " <h1>자바 환경정보</h1>\r\n" | |
| + " <table>\r\n" | |
| + " <tr>\r\n" | |
| + " <th>키</th>\r\n" | |
| + " <th></th>\r\n" | |
| + " </tr>\r\n"); | |
| for(Object k : System.getProperties().keySet()) { | |
| String key = k.toString(); | |
| String value = System.getProperty(key); | |
| sb.append("<tr>\r\n"); | |
| sb.append(" <td>");sb.append(key);sb.append("</td>\r\n" | |
| + " <td>");sb.append(value);sb.append("</td>\r\n" | |
| + " </tr>\r\n"); | |
| } | |
| sb.append(" </table>\r\n" | |
| + "</body>\r\n"); | |
| try { | |
| File file = new File("./property.html"); | |
| BufferedWriter writer = new BufferedWriter(new FileWriter(file)); | |
| writer.write(sb.toString()); | |
| writer.close(); | |
| } catch(IOException e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment