Author: richard.opalka(a)jboss.com
Date: 2008-09-30 05:16:27 -0400 (Tue, 30 Sep 2008)
New Revision: 8296
Modified:
common/trunk/src/main/java/org/jboss/wsf/test/XOPTestSupport.java
Log:
[JBWS-2322] ensure cleanup
Modified: common/trunk/src/main/java/org/jboss/wsf/test/XOPTestSupport.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/test/XOPTestSupport.java 2008-09-30 07:41:38
UTC (rev 8295)
+++ common/trunk/src/main/java/org/jboss/wsf/test/XOPTestSupport.java 2008-09-30 09:16:27
UTC (rev 8296)
@@ -24,16 +24,18 @@
import java.awt.Image;
import java.awt.Toolkit;
import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import javax.activation.DataHandler;
import javax.xml.transform.stream.StreamSource;
+import org.jboss.wsf.common.IOUtils;
+
/**
* @author Heiko Braun <heiko.braun(a)jboss.com>
* @since 22-Sep-2006
@@ -43,20 +45,9 @@
public static byte[] getBytesFromFile(File file) throws IOException
{
- InputStream is = new FileInputStream(file);
-
- long length = file.length();
- byte[] bytes = new byte[(int)length];
-
- int offset = 0;
- int numRead = 0;
- while (offset < bytes.length && (numRead = is.read(bytes, offset,
bytes.length - offset)) >= 0)
- {
- offset += numRead;
- }
-
- is.close();
- return bytes;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ IOUtils.copyStream(baos, new FileInputStream(file));
+ return baos.toByteArray();
}
public static Image createTestImage(File imgFile)
Show replies by date