1. java zip 多個文件時,如果先添加了一個excel文件,然后再想添加其他的文件時會出現 steam is closed的錯誤。這是因為work.write(outputSteam)后,出調用outputSteam.close(),關閉輸出流。
解決方法:
將原來的程序:
其中 NonCloseableOutputStream 定義如下:
2. 使用binary使得mysql區分大小寫
select * from table1 where binary field1 = 'abc';
解決方法:
將原來的程序:
ZipEntry entry = new ZipEntry( "file3.txt" );
zos.putNextEntry( entry );
workbook.write( zos );
zos.closeEntry();
改為:zos.putNextEntry( entry );
workbook.write( zos );
zos.closeEntry();
ZipEntry entry = new ZipEntry( "file3.txt" );
zos.putNextEntry( entry );
workbook.write( new NonCloseableOutputStream( zos ) );
zos.closeEntry();
zos.putNextEntry( entry );
workbook.write( new NonCloseableOutputStream( zos ) );
zos.closeEntry();
其中 NonCloseableOutputStream 定義如下:
public class NonCloseableOutputStream extends java.io.FilterOutputStream {
public NonCloseableOutputStream(OutputStream out) {
super(out);
}
@Override public void close() throws IOException {
flush();
}
}
public NonCloseableOutputStream(OutputStream out) {
super(out);
}
@Override public void close() throws IOException {
flush();
}
}
2. 使用binary使得mysql區分大小寫
select * from table1 where binary field1 = 'abc';
posted @ 2017-08-09 19:52 云自無心水自閑 閱讀(425) | 評論 (0) | 編輯 收藏