首页 > 学院 > 开发设计 > 正文

Java操作文本文件中的中文

2019-11-18 14:31:48
字体:
来源:转载
供稿:网友

  try{
RandomaccessFile rf=new RandomAccessFile("e://my.txt","rw");
String str="中文";
byte [] b;
b=str.getBytes();
rf.write(b);//中文就写入文本文件了。
}
catch(Exception e){}

try{
BufferedReader br=new BufferedReader(new FileReader("e://my.txt"));
while((line=br.readLine())!=null)
{
System.out.PRintln(line);//读取文件
}}
catch(Exception e){}

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表