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

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

          Posted on 2008-12-22 14:35 G_G 閱讀(3628) 評論(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();
          ????????}

          ??????}


          主站蜘蛛池模板: 永宁县| 辉县市| 新巴尔虎左旗| 深泽县| 祥云县| 大化| 丹江口市| 柳河县| 新泰市| 双牌县| 巴青县| 山西省| 庆元县| 凤凰县| 曲阜市| 巫山县| 什邡市| 黑水县| 和静县| 南宁市| 仪征市| 吉木萨尔县| 贺兰县| 炎陵县| 建平县| 疏附县| 沅江市| 额尔古纳市| 崇礼县| 资源县| 保定市| 江口县| 康保县| 宝山区| 岳阳县| 黔西县| 吉隆县| 正定县| 贡山| 文化| 华池县|