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 阅读(664) 评论(0)  编辑  收藏 所属分类: 测试学习专栏


只有注册用户登录后才能发表评论。


网站导航:
 
<2014年4月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

导航

统计

常用链接

留言簿(55)

随笔分类

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜