I have this piece of code, which is to write Ojbect into a stream of byte arrays:
static byte[] toBytes(MyTokens tokens) throws IOException { ByteArrayOutputStream out = null; ObjectOutput s = null; try { out = new ByteArrayOutputStream(); try { s = new ObjectOutputStream(out); s.writeObject(tokens); } finally { try { s.close(); } catch (Exception e) { throw new CSBRuntimeException(e); } } } catch (Exception e) { throw new CSBRuntimeException(e); } finally { IOUtils.closeQuietly(out); } return out.toByteArray(); }
However, FindBugs continues to complain about the line:
s = new ObjectOutputStream(out);
that "may not close the stream" - BAD_PRACTICE - OS_OPEN_STREAM. Can anyone help?
java stream findbugs software-quality
Eugene
source share