/*
 * HelloHangul.java
 *
 *    컴파일: javac -classpath .;iText-rtf-2.1.4.jar;iText-2.1.4.jar HelloHangul.java
 *      실행: java -cp .;iText-rtf-2.1.4.jar;iText-2.1.4.jar HelloHangul *
 */
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Paragraph;
import com.lowagie.text.rtf.RtfWriter2;
public class HelloHangul {
    public static void main(String[] args) {
        System.out.println("Hello, 한글! RTF 파일 생성됨");
        try {
            // 도큐먼트 생성
            Document document = new Document();
            
            // RtfWriter2 생성
            RtfWriter2.getInstance(document, new FileOutputStream("HelloHangul.rtf"));
            
            // 도큐먼트 열기
            document.open();
            
            // Step 4: Add content to the document.
            document.add(new Paragraph("Hello, 한글!"));
            
            // 도큐먼트 닫기
            document.close();
        } catch (FileNotFoundException fnfe) {
            // 파일을 생성 할 수 없을 때
            fnfe.printStackTrace();
        } catch (DocumentException de) {
            // DocumentExceptions arise if you add content to the document before opening or
            // after closing the document.
            // 도큐먼트를 열기 전이나 닫은 후의 예외상황 발생
            de.printStackTrace();
        }
    }
}
 
'프로그래밍 > Java' 카테고리의 다른 글
| Pollard's rho method 소개: 정수의 인수분해(factorizing integers) with Java (0) | 2009.03.24 | 
|---|---|
| 손으로 계산하는 긴자리 곱셈표 만들기 with Java (0) | 2009.03.06 | 
| Hello Swing 애플리케이션 예제 for Java (0) | 2009.01.29 | 
| Hello AWT 애플리케이션 예제 for Java (0) | 2009.01.29 | 
| 문자열 거꾸로 하기 with Java (0) | 2009.01.25 |