import java.io.*; publicclass StreamEncoderClose { publicstaticvoid main( String arg[] ) throws Exception { byte[] expected = {(byte)0x1b,(byte)0x24,(byte)0x42,
(byte)0x30,(byte)0x6c,
(byte)0x1b,(byte)0x28,(byte)0x42};
ByteArrayOutputStream baos = new ByteArrayOutputStream();
MyBufferedOutputStream mbos = new MyBufferedOutputStream(baos);
PrintWriter pw = new PrintWriter(new OutputStreamWriter(mbos, "ISO-2022-JP"));
mbos.dontClose();
pw.write("\u4e00");
pw.close(); // 1st PrintWriter Close
mbos.canClose();
pw.close(); // 2nd PrintWriter Close
//double check, probably not necessary byte[] out = baos.toByteArray(); if (out.length != expected.length) { thrownew IOException("Failed");
} for (int i = 0; i < out.length; i++) { //System.out.printf("(byte)0x%x,", out[i] & 0xff); if (out[i] != expected[i]) thrownew IOException("Failed");
}
}
staticclass MyBufferedOutputStream extends BufferedOutputStream {
MyBufferedOutputStream(OutputStream os) { super(os);
} privateboolean status; publicvoid dontClose() {
status = false;
} publicvoid canClose() {
status = true;
} publicvoid close() throws IOException { if ( status == false ) { thrownew IOException("Can't close ");
} super.close();
}
}
}
Messung V0.5 in Prozent
¤ 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.0.1Bemerkung:
(vorverarbeitet am 2026-09-30)
¤
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.