posts - 165, comments - 198, trackbacks - 0, articles - 1
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          java gzip (使用,亂碼問題已解決!)

          Posted on 2008-12-22 14:35 G_G 閱讀(3627) 評論(0)  編輯  收藏 所屬分類: javaGeneral




          ???? public ? static ? void ?main(String[]?args)? {
          ????????
          try ? {
          ????????
          ?????????String?charset?
          = ? " UTF-8 " ;
          ?????????String?outfile?
          = ? " d:\\category.20081218.gz " ;
          ?????????BufferedReader?in?
          = ? new ?BufferedReader(
          ??????????
          new ?InputStreamReader(
          ??????????
          new ?FileInputStream( " d:\\category.20081218 " ),
          ??????????charset));
          ??????????
          ??????????BufferedOutputStream?out?
          =
          ????????????
          new ?BufferedOutputStream(
          ??????????????
          new ?GZIPOutputStream(
          ????????????????
          new ?FileOutputStream(outfile)));
          ??????????
          ??????????
          ??????????System.out.println(
          " Writing?file " );
          ??????????String?c;
          ??????????
          while ((c? = ?in.readLine()) != null )
          ????????????out.write(?(c
          + " \n " ).getBytes(charset));
          ??????????in.close();
          ??????????out.close();
          ??????????System.out.println(
          " Reading?file " );
          ??????????BufferedReader?in2?
          =
          ????????????
          new ?BufferedReader(
          ??????????????
          new ?InputStreamReader(
          ????????????????
          new ?GZIPInputStream(
          ??????????????????
          new ?FileInputStream(outfile)
          ??????????????????),charset
          ????????????????)
          ??????????????);
          ??????????String?s;
          ??????????
          while ((s? = ?in2.readLine())? != ? null )
          ????????????System.out.println(s);
          ????????}
          ? catch (Exception?e)? {
          ??????????e.printStackTrace();
          ????????}

          ??????}


          主站蜘蛛池模板: 登封市| 乌鲁木齐市| 张掖市| 德保县| 剑河县| 永和县| 松滋市| 阳西县| 新泰市| 壶关县| 武定县| 黄石市| 东乌| 桐柏县| 游戏| 淮滨县| 杭锦后旗| 陆良县| 栾城县| 大宁县| 芜湖市| 渑池县| 汶上县| 青浦区| 文成县| 潍坊市| 临安市| 伊宁县| 亚东县| 嘉祥县| 沧源| 大同县| 榆林市| 龙陵县| 双城市| 黄梅县| 连南| 潍坊市| 益阳市| 华池县| 铜山县|