1. java zip 多個文件時,如果先添加了一個excel文件,然后再想添加其他的文件時會出現(xiàn) steam is closed的錯誤。這是因為work.write(outputSteam)后,出調(diào)用outputSteam.close(),關(guān)閉輸出流。
解決方法:
將原來的程序:
其中 NonCloseableOutputStream 定義如下:
2. 使用binary使得mysql區(qū)分大小寫
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區(qū)分大小寫
select * from table1 where binary field1 = 'abc';