posts - 165, comments - 198, trackbacks - 0, articles - 1
            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

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

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

          ??????}


          主站蜘蛛池模板: 阜康市| 滨海县| 渝北区| 麟游县| 阜康市| 林周县| 延庆县| 社会| 静海县| 芒康县| 洞口县| 青冈县| 古交市| 民丰县| 慈溪市| 林西县| 丹棱县| 尼勒克县| 祁东县| 临猗县| 西平县| 五家渠市| 青田县| 乡城县| 专栏| 长宁区| 金堂县| 甘孜县| 墨竹工卡县| 上犹县| 永丰县| 柘城县| 周宁县| 成武县| 青岛市| 晋城| 马龙县| 柘城县| 玉环县| 黔南| 锦屏县|