• Post Reply Bookmark Topic Watch Topic
  • New Topic

Data Type to Hold Rich Text in Java  RSS feed

 
bala kannan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a basic question. I want to know how to store rich text content in java. Is there any specific data type to hold such data without affecting the original data. I should be in a position to store the rich text content on to some variable(of data type that supports RTF) and retrieve it when ever required.

We don use swings here. Also this requirement should be met without file handling. Please help me in this regard.



 
Tim Moores
Saloon Keeper
Posts: 4019
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String is a natural type for text data; it should work fine for RTF. Binary document types (like PDF) would require a byte[].
 
bala kannan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply tom.

The scenario goes like this. From the client side(EXTjs) i will be collecting the text sent in RTF. I need to first grab with some data type that supports RTF in java and then store the same in database and retieve it( without affecting the format of the text). Will it be possible using Strings? If i store strings in DB as varchar, the entire format of rich text will be lost rite?

I had thought of file handling by capturing the text from client in a RTF file and then storing the file as a BLOB object in DB. But the idea is rejected here.
Please help.
 
Tim Moores
Saloon Keeper
Posts: 4019
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RTF is text, so a BLOB would be inappropriate anyway. A CLOB would work, but an unlimited varchar is just as good.

Why would the formatting be lost if you store it in the DB? I suggest you do some studying and experimenting with RTF if you're serious about working with it.
 
bala kannan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim, formatting in the sense i meant about the bold and italicized content. I am not sure when i store a bolded and Italized text(of String data type as you suggested) on to varchar will it be same or not.

As suggested i will implement the way you suggested rtf text stored in a String(Java Side) and the same in database (either varchar or clob). Hope it works successfully.
 
Tim Moores
Saloon Keeper
Posts: 4019
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Storing something in a String or a DB varchar does not alter it in any way. But I still recommend that you examine how RTF works, for example how bold, italics etc. work, so that you have a chance to look into an RTF file and get an idea of what's inside, and whether or not it looks superficially OK.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!