Skip to content

Instantly share code, notes, and snippets.

@dkwktm45
Last active July 12, 2023 07:38
Show Gist options
  • Select an option

  • Save dkwktm45/5746288a588be9474c03d7075f57c357 to your computer and use it in GitHub Desktop.

Select an option

Save dkwktm45/5746288a588be9474c03d7075f57c357 to your computer and use it in GitHub Desktop.
import java.io.*;
import java.util.HashMap;
public class mission1 {
public static void main(String[] args) {
HashMap<String, String> map = new HashMap<>();
for (Object k : System.getProperties().keySet()) {
String key = k.toString();
String value = System.getProperty(key);
map.put(key, value);
}
try {
File file = new File("property.html");
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
writer.write("<head>");
writer.write("\r\n\t <meta charset=\\\"UTF-8\\\"/>");
writer.write("\r\n\t <style>\r\n\t\t");
writer.write("table {border-collapse:collapse; width:100%;}");
writer.write("\r\n\t\t th,td{border:solid 1px #000; text-align: left;}");
writer.write("\r\n\t\t body > table > tbody > tr:nth-child(1) > th:nth-child(1) {text-align: center;}");
writer.write("\r\n\t </style>\r\n</head>");
/*테이블 생성*/
writer.write("\r\n <body>\r\n<h1>자바 환경정보</h1><table>\r\n");
writer.write("\r\n\t<tr>");
writer.write("\r\n\t\t<th>키</th><th></th></tr>");
for (String key : map.keySet()) {
writer.write(String.format("\r\n\t\t<tr><th>%s</th><th>%s</th></tr>", key , System.getProperty(key)));
}
writer.write("</table>\r\n" +
"</body>\r\n" +
"</html>");
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