• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Read RTF File from Java

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello mam/sir
How cani read RTF file from java.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

That depends on what you want to do with the file contents. Fundamentally, RTF is just a text file, so you can use the File, FileInputStream and various Reader classes in the java.io package.

If you want to display RTF in a Swing component, have a look at this sample application which does exactly that.
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sunilkumarbit choudhary:
How can i read RTF file from java



Keep in mind that RTF is not really a standard. Microsoft documents it poorly and amends it whenever it sees fit. That said, reading an RTF file can be as easy as:

JEditorPane jep = new JEditorPane("application/rtf", "");
jep.read(new FileInputStream("path/to/file.rtf"), null);
yourContainer.add(new JScrollPane(jep));

I hope this is helpful.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic