云自無心水自閑

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

          記錄備忘

          Posted on 2017-08-09 19:52 云自無心水自閑 閱讀(442) 評論(0)  編輯  收藏
          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';


          只有注冊用戶登錄后才能發表評論。


          網站導航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          主站蜘蛛池模板: 和平县| 大安市| 元朗区| 自贡市| 崇文区| 富裕县| 汝州市| 琼结县| 屏山县| 乌兰察布市| 卓尼县| 平邑县| 德江县| 永善县| 宝鸡市| 镇原县| 咸阳市| 玉环县| 北票市| 阿图什市| 山东| 柳江县| 莱阳市| 徐州市| 永吉县| 盐池县| 开化县| 泽普县| 孟津县| 静海县| 庆云县| 绥江县| 西丰县| 广东省| 石柱| 肃南| 高阳县| 大同县| 商丘市| 卢氏县| 高安市|