how to save rich text format in database using java

Solutions on MaxInterview for how to save rich text format in database using java by the best coders in the world

showing results for - "how to save rich text format in database using java"
Ariana
04 Apr 2018
1string rtfText; //string to save to db
2TextRange tr = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);
3using (MemoryStream ms = new MemoryStream())
4{
5    tr.Save(ms, DataFormats.Rtf);
6    rtfText = Encoding.ASCII.GetString(ms.ToArray());
7}
8
Imen
09 Oct 2018
1string rtfText= ... //string from db
2byte[] byteArray = Encoding.ASCII.GetBytes(rtfText);
3using (MemoryStream ms = new MemoryStream(byteArray))
4{
5    TextRange tr = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);
6    tr.Load(ms, DataFormats.Rtf);
7}
8