qileilove

          blog已經轉移至github,大家請訪問 http://qaseven.github.io/

          Java使用字符流拷貝文件出現亂碼

           Java代碼
          //      BufferedReader in = null;
          //      BufferedWriter out = null;
          Reader in = null;
          Writer out = null;
          try {
          //          in = new BufferedReader(new FileReader(src));
          //          in = new BufferedReader(new InputStreamReader(new FileInputStream(src)));
          //          out = new BufferedWriter(new FileWriter(new File(dir, src.getName())));
          //          out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, src.getName()))));
          in = new FileReader(src);
          out = new FileWriter(new File(dir, src.getName()));
          System.out.println("正在拷貝文件(" + src + ")到目錄("+dir+")下");
          char[] buffer = new char[1024];
          int len = 0;
          while((len = in.read(buffer)) != -1) {
          out.write(buffer, 0, len);
          out.flush();
          }
          return true;
          } catch (Exception e) {
          return false;
          } finally {
          closeIO(in, out);
          }
            亂碼情況
          <img src="http://img.blog.csdn.net/20140414090344562?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaWNlcl93ZWk=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">
            怎樣解決?
            我想知道這種情況是怎么造成的?又該怎樣解決?

          posted on 2014-04-16 11:22 順其自然EVO 閱讀(666) 評論(0)  編輯  收藏 所屬分類: 測試學習專欄

          <2014年4月>
          303112345
          6789101112
          13141516171819
          20212223242526
          27282930123
          45678910

          導航

          統計

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 昌吉市| 贞丰县| 滦南县| 阳东县| 颍上县| 杨浦区| 开阳县| 威远县| 和顺县| 神木县| 龙江县| 贵溪市| 恩施市| 奉节县| 康马县| 盐亭县| 刚察县| 北川| 乐都县| 花莲县| 康马县| 山丹县| 盐边县| 进贤县| 秦安县| 江西省| 嘉黎县| 安吉县| 峨边| 泰和县| 尼玛县| 杭锦后旗| 涡阳县| 台江县| 哈巴河县| 安顺市| 略阳县| 龙井市| 岳阳市| 绥阳县| 镇雄县|