일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
31 |
- Android
- 안드로이드
- Spring Security
- jobtoy
- s4a
- 리브레캐드
- html5
- 설정
- 스크래치
- 코딩
- 강좌
- 유니티
- jsp
- 잡토이 메이킹 코딩 학원
- 잡토이
- librecad
- 아두이노
- 오라클
- tomcat
- MSSQL
- Unity
- mysql
- 시작하기
- 톰캣
- 파주
- oracle
- 운정
- 예제
- 설치
- 라즈베리파이
- Today
- Total
랩제이
[java] 파일 템플릿 replace 소스 본문
프로젝트 템플릿을 제작하는데 원본 파일을 두고 replace만 할 수 있도록 하기 위한 기본 소스임
* templet source
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="200" height="63" valign="top" style="padding:10px 0px 0px 15px;"><img src="https://www.samsungdmcc.com/commons/images/sub_layoutbot_001.gif" width="200" height="63"></td>
<td style="padding:10px 0px 10px 10px;"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="padding-bottom:5px;"> $footer1$<br></td>
</tr>
<tr>
<td height="1px" class=" bgcol_darkgray"></td>
</tr>
<tr>
<td height="10" style="padding-top:5px;">$footer2$</td>
</tr>
<tr>
<td height="10" style="font-family:Arial; font-size:10px;">$footer3$</td>
</tr>
</table></td>
</tr>
</table>
* java source
package com.jobtoy.sample1;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
public class ex1 {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
// D:\public\BoardController.java
BufferedReader freader = new BufferedReader( new InputStreamReader(new FileInputStream("D:/public/BoardController.java"),"utf-8") ) ;
String line = null;
StringBuilder sb = new StringBuilder();
while ((line = freader.readLine()) != null) {
sb.append(line+"\n");
}
freader.close();
String emailTemplage = sb.toString();
String emailBody = "";
///////////// template 에 내용적용 //////////////////////
emailTemplage = emailTemplage.replaceAll("[$]footer1[$]", "test1");
emailTemplage = emailTemplage.replaceAll("[$]footer2[$]", "test2");
emailTemplage = emailTemplage.replaceAll("[$]footer3[$]", "test3");
emailBody = emailTemplage.replaceAll("[$]mail_title[$]", "test4");
emailBody = emailBody.replaceAll("[$]mail_contents[$]", "test5");
System.out.println(emailBody);
}
}
'programming > java' 카테고리의 다른 글
[java] md5 aes128 mysql 암호화 적용 (0) | 2017.02.07 |
---|---|
우분투 자바 설치 (0) | 2016.07.11 |
[java] AES 암호화 샘플 (0) | 2014.03.05 |
[java] commons-fileupload (0) | 2013.07.03 |
[java] commons-codec (0) | 2013.07.03 |