// Create a FileCacheImageOutputStream from a ByteArrayOutputStream
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageOutputStream fcios2 = ImageIO.createImageOutputStream(baos);
BufferedImage bi = new BufferedImage(10, 10, BufferedImage.TYPE_3BYTE_BGR);
// It should not be necessary to flush any of the streams // If flushing does make a difference, it indicates a bug // in the writer or the stream implementation
// Get length of temp1 before and after flushing long file1NoFlushLength = temp1.length();
fios.flush(); long file1FlushLength = temp1.length();
// Get length of temp2 before and after flushing long file2NoFlushLength = temp2.length();
fcios1.flush();
bos.flush(); long file2FlushLength = temp2.length();
byte[] b0 = baos.toByteArray(); int cacheNoFlushLength = b0.length;
fcios2.flush(); byte[] b1 = baos.toByteArray(); int cacheFlushLength = b1.length;
if (file1NoFlushLength != file1FlushLength) { // throw new RuntimeException
System.out.println
("FileImageOutputStream not flushed!");
}
if (file2NoFlushLength != file2FlushLength) { // throw new RuntimeException
System.out.println
("FileCacheImageOutputStream/BufferedOutputStream not flushed!");
}
if (cacheNoFlushLength != cacheFlushLength) { // throw new RuntimeException
System.out.println
("FileCacheImageOutputStream/ByteArrayOutputStream not flushed!");
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.