👤
Home Man
Search
Today's Posts
Register

Post questions about C, C++, Java, SQL, and other programming languages here.

RTFEditorKit - Write to RTF File

👤 Login to reply

 
Thread Tools Search this Thread
# 1  
Old 09-21-2017
RTFEditorKit - Write to RTF File

Hi,
I am looking at writing the BLOB from database which is an rtf data to write to RTF file.
I am trying to use the RTFEditorKit for the same and was struck with the write API it provides.

write API takes the outstream and Document, all I have is Inputstream or bytestream from database - how do I convert the stream data to a Java Document object.

Code:
FileOutputStream outputStream = new FileOutputStream("C:\\blobfile.rtf");
            RTFEditorKit rtf = new RTFEditorKit();
            
            

            Document doc = rtf.createDefaultDocument();
           
            
                rtf.write(outputStream, lob.getBinaryStream(0, lob.length()), 0, doc.getLength());


Thank You,


Moderator's Comments:
RTFEditorKit - Write to RTF File Please use CODE tags as required by forum rules!

Last edited by RudiC; 09-21-2017 at 12:59 PM.. Reason: Added CODE tags.
# 2  
Old 09-21-2017
Java can write binary data to a file just fine without RTFEditorKit's help.

Code:
FileOutputStream rtf = new FileOutputStream("blobfile.rtf");
    rtf.write(lob); // code may vary depending on what 'lob' actually is
    rtf.close();

# 3  
Old 09-21-2017
Quote:
Originally Posted by Corona688
Java can write binary data to a file just fine without RTFEditorKit's help.

Code:
FileOutputStream rtf = new FileOutputStream("blobfile.rtf");
    rtf.write(lob); // code may vary depending on what 'lob' actually is
    rtf.close();


Problem is it's writing the raw data which is with all the tags, It's not recognizing as rtf format data, when i open the file in RTF editor i see all the tags and content instead of just content, any way i can eliminate?
# 4  
Old 09-21-2017
You asked for 'writing to a file'. You can do that with FileOutputStream. Did you actually mean 'open in RTFEditorKit'?

My suggestion for that would be to write to a file with FileOutputStream, close it, then use RTFEditorKit to open the file.
# 5  
Old 09-21-2017
It's my bad, i am working on a corrupted rtf file and was trying all sort of things. The binary stream works if the file is not corrupted.

Thank You for the reply.
# 6  
Old 09-22-2017
If the file is too corrupted to make sense of, you'll have to fix it first.
👤 Login to reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Replacing duplicated extensions, like .rtf.rtf OmarKN UNIX for Dummies Questions & Answers 6 11-05-2014 03:22 PM
Compare 2 text file with 1 column in each file and write mismatch data to 3rd file Divya Nochiyil Shell Programming and Scripting 10 11-04-2013 08:45 AM
Match list of strings in File A and compare with File B, C and write to a output file in CSV format asnandhakumar Shell Programming and Scripting 6 10-11-2012 03:47 PM
read/write,write/write lock with smbclient fails swatidas11 IP Networking 1 03-05-2010 10:26 AM
how to convert XLS to CSV and DOC/RTF to TXT prvnrk Shell Programming and Scripting 1 04-23-2009 02:47 PM
looking for convert rtf to pdf utility umen UNIX and Linux Applications 2 03-04-2009 04:07 AM
Problem to send rtf inline body srik_ux UNIX for Dummies Questions & Answers 7 05-30-2008 11:30 AM
embedded exe file into rtf file rawatds Shell Programming and Scripting 1 12-06-2004 05:52 AM
RTF files can they be converted once they are on linux system moxxx68 Windows & DOS: Issues & Discussions 7 09-12-2004 01:26 PM
converting PDF to text, rtf doc format saurya_s UNIX for Advanced & Expert Users 1 04-23-2004 03:25 PM


All times are GMT -4. The time now is 02:52 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
×
UNIX.COM Login
Username:
Password:  
Show Password