CVS: jfor/src/org/jfor/jfor/rtflib/rtfdoc RtfExternalGraphic.java,1.6,1.7

Marra Roberto <[email protected]> Wed, 05 Jun 2002 10:43:27 -0700
Newsgroups gmane.text.xml.jfor.cvs
Message-ID <[email protected]>
Update of /cvsroot/jfor/jfor/src/org/jfor/jfor/rtflib/rtfdoc
In directory usw-pr-cvs1:/tmp/cvs-serv1369

Modified Files:
	RtfExternalGraphic.java 
Log Message:
 reading from a stream using InputStream.availiable() bug fixed.

Index: RtfExternalGraphic.java
===================================================================
RCS file: /cvsroot/jfor/jfor/src/org/jfor/jfor/rtflib/rtfdoc/RtfExternalGraphic.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** RtfExternalGraphic.java	28 Dec 2001 17:08:50 -0000	1.6
--- RtfExternalGraphic.java	5 Jun 2002 17:43:24 -0000	1.7
***************
*** 10,13 ****
--- 10,17 ----
  import org.jfor.jfor.tools.jpeg.JPEGException;
  
+ import java.io.BufferedInputStream;
+ import java.io.BufferedOutputStream;
+ import java.io.InputStreamReader;
+ 
  import java.io.ByteArrayOutputStream;
  import java.io.InputStream;
***************
*** 198,210 ****
  		getRtfFile ().getLog ().logInfo ("Writing image '" + url + "'.");
  
  		byte[] data = null;
  		try
  		{
! 			InputStream in = url.openStream();
! 			int count = in.available();
! 
! 			data = new byte[count];
! 
! 			in.read(data, 0, count);
  		}
  		catch (Exception e) {
--- 202,218 ----
  		getRtfFile ().getLog ().logInfo ("Writing image '" + url + "'.");
  
+ 
  		byte[] data = null;
  		try
  		{
!         	final BufferedInputStream bin = new BufferedInputStream(url.openStream());
!          	final ByteArrayOutputStream bout = new ByteArrayOutputStream();
!           	while (true) {
!           		final int datum = bin.read();
!              	if (datum == -1) break;
!               	bout.write(datum);
!              }
!              bout.flush();
!              data = bout.toByteArray();
  		}
  		catch (Exception e) {


_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm