Hi,
I am trying to write a code to combine RTF file and TIFF file into an output RTF file. That means, output RTF file should have RTF file contents at the top followed by TIFF image. The code is:

import java.io.*;

public class RTFTest
{
public RTFTest(String rtfFile, String tifFile)
{
try
{
BufferedInputStream bis = new BufferedInputStream (new FileInputStream (new File(rtfFile)));
int iAvailable = bis.available();
byte[] b = new byte[iAvailable];
bis.read (b, 0, iAvailable);
bis.close();

BufferedInputStream bis2 = new BufferedInputStream (new FileInputStream (new File(tifFile)));
int iAvailable2 = bis2.available();
byte[] b2 = new byte[iAvailable2];
bis2.read (b2, 0, iAvailable2);
bis2.close();

BufferedOutputStream bos = new BufferedOutputStream (new FileOutputStream (new File("output.rtf")));
bos.write (b, 0, iAvailable);
bos.write (b2, 0, iAvailable2);
bos.flush();
bos.close();
}
catch(Exception ex)
{
ex.printStackTrace();
}
}

public static void main(String args[])
{
new RTFTest("./input.rtf", "./test.tif");
}
}

But, when I open the output.tif, I could only see RTF contents. Not sure what happened to the TIFF contents written onto it. Please help me with this.

Regards,

 

 

 


Comment/Reply (w/o sign-up)