HelloWorldRtf.java Source code

Java tutorial

Introduction

Here is the source code for HelloWorldRtf.java

Source

import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.rtf.RtfWriter2;

public class HelloWorldRtf {
    public static void main(String[] args) {
        try {
            Document document = new Document();
            RtfWriter2.getInstance(document, new FileOutputStream("HelloWorldRtf.rtf"));
            document.open();
            document.add(new Paragraph("Hello World!"));
            document.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}