云自無心水自閑

          天平山上白云泉,云自無心水自閑。何必奔沖山下去,更添波浪向人間!
          posts - 288, comments - 524, trackbacks - 0, articles - 6
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          2017年8月9日

          1. java zip 多個文件時,如果先添加了一個excel文件,然后再想添加其他的文件時會出現 steam is closed的錯誤。這是因為work.write(outputSteam)后,出調用outputSteam.close(),關閉輸出流。
          解決方法:
          將原來的程序:
                      ZipEntry entry = new ZipEntry( "file3.txt" );
                      zos.putNextEntry( entry );
                      workbook.write( zos );
                      zos.closeEntry();
          改為:
                      ZipEntry entry = new ZipEntry( "file3.txt" );
                      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();
              }
          }



          2. 使用binary使得mysql區分大小寫
          select * from table1 where binary field1 = 'abc';

          posted @ 2017-08-09 19:52 云自無心水自閑 閱讀(442) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 比如县| 兰州市| 那坡县| 信丰县| 中牟县| 雷州市| 阿瓦提县| 石泉县| 梅河口市| 永靖县| 沈阳市| 广东省| 民丰县| 乌鲁木齐县| 罗田县| 乐至县| 平南县| 安龙县| 鹤庆县| 石泉县| 三亚市| 桂阳县| 虎林市| 江华| 崇左市| 通辽市| 扎赉特旗| 永春县| 米易县| 上犹县| 凭祥市| 娱乐| 新宁县| 彰化县| 南陵县| 汤阴县| 砚山县| 万州区| 台湾省| 和政县| 彭州市|