Home Man
Search
Today's Posts
Register

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

RTFEditorKit - Write to RTF File

Tags
programming

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
Need help to write a shell script to convert text file to excel file. akabhinav18 Shell Programming and Scripting 8 10-13-2015 06:18 AM
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
Need to search a particular String form a file a write to another file using perl script Raysf Shell Programming and Scripting 2 09-20-2013 05:22 PM
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
how read specific line in a file and write it in a new text file? vel4ever Shell Programming and Scripting 6 02-15-2012 06:40 AM
Lookup two values per line (from a second file) and write the smaller value to another file genehunter Shell Programming and Scripting 3 04-28-2010 01:06 PM
Some how the open(file,flag, acc) returns 0 and write to the screen, instead of the file ??? alex_5161 Programming 2 03-08-2010 03:36 PM
read/write,write/write lock with smbclient fails swatidas11 IP Networking 1 03-05-2010 10:26 AM
How to delete a string pattern in a file and write back to the same file mwrg Shell Programming and Scripting 1 11-18-2009 05:30 AM
Need to write a script in UNIX to find a file if another file exists mmdawg Shell Programming and Scripting 1 05-04-2008 10:40 PM


All times are GMT -4. The time now is 07:59 AM.

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