Fixed closing ObjectOutputStream (SMACK-143).

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2340 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2004-07-13 00:39:30 +00:00 committed by mtucker
parent d471d42fbf
commit 677b389ccc
1 changed files with 13 additions and 3 deletions

View File

@ -424,16 +424,26 @@ public abstract class Packet {
// a binary format, which won't work well inside of XML. Therefore, we base-64
// encode the binary data before adding it.
else {
ByteArrayOutputStream byteStream = null;
ObjectOutputStream out = null;
try {
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(byteStream);
byteStream = new ByteArrayOutputStream();
out = new ObjectOutputStream(byteStream);
out.writeObject(value);
buf.append("java-object\">");
String encodedVal = StringUtils.encodeBase64(byteStream.toByteArray());
buf.append(encodedVal).append("</value>");
}
catch (Exception e) {
e.printStackTrace();
}
finally {
if (out != null) {
try { out.close(); } catch (Exception e) { }
}
if (byteStream != null) {
try { byteStream.close(); } catch (Exception e) { }
}
}
}
buf.append("</property>");