1 Reply Latest reply: Oct 15, 2008 6:23 AM by 800322 RSS

    how can add a images file  to anothere image file

    807589
      hi

      Requirement is: i have one image in data base , i is show to user in my application
      know we want add another image file in to a current image file (just append)
      at end .

      i was tried with following code below


      i was read the previous(Old) image content from the data base and placed into c:\\ReArchive\\test_content.tiff

      ResultSet rs2=dbBean.getSQLRows("select binarycontent from ContentVersion where contentindex="+IndexValue+"");

      byte[] bTempData_content=new byte[65536];

      while(rs2.next()){              
      File f = new File("c:\\ReArchive\\test_content.tiff");
      f_content.delete();
      f_content.createNewFile();
      FileOutputStream dest_contentVersion = new FileOutputStream(f_content);
      while(rs2.next()){              

      InputStream is_content=rs2.getBinaryStream("Binarycontent");
      nActualRead_content=is.read(bTempData_content,0,65536);
      while(nActualRead_content>0)
      {
      dest_contentVersion.write(bTempData_content,0,nActualRead_content);
      nActualRead_content=is.read(bTempData_content,0,65536);
      }
      }
      -------------------------------------------------------------------------------------------------------------

      Then i was took New image file from data base and place in to c:\\ReArchive\\test.tiff");

      int nActualRead=0;
      ResultSet rs1=dbBean.getSQLRows("select * from Object_Store where Barcode_ID='"+strBar_Code+"'");
      byte[] bTempData=new byte[65536];

      File f = new File("c:\\ReArchive\\test.tiff");
      f.delete();
      f.createNewFile();
      FileOutputStream dest = new FileOutputStream(f);
      while(rs1.next()){
      InputStream is=rs1.getBinaryStream("Obj_Content");
      nActualRead=is.read(bTempData,0,65536);
      while(nActualRead>0)
      {
      dest.write(bTempData,0,nActualRead);
      nActualRead=is.read(bTempData,0,65536);
      }
      }

      ---------------------------------------------------------------------------------------------------------------------

      then i tried add two images by converting InputStream to String and i am trying add to images

      but i was failed ,i think i am in not correct way , how can i solve this problem


      thanks advance
      gss