Chinaunix首页 | 论坛 | 博客
  • 博客访问: 39414
  • 博文数量: 17
  • 博客积分: 350
  • 博客等级: 一等列兵
  • 技术积分: 180
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-08 00:09
文章分类
文章存档

2011年(17)

我的朋友

分类: Java

2011-04-06 23:07:19

xbjiang 标签:

package Iec104Config;

import java.io.*;

public class Test {
    public static void main(String[] args)throws IOException{
                String stringToBeSaved="测\naa";
                FileWriter saveFile=new FileWriter("Test.txt", false);
                PrintWriter savedOut=new PrintWriter(saveFile);
                savedOut.print(stringToBeSaved+"\n");
                savedOut.close();           
                RandomAccessFile Open= new RandomAccessFile("Test.txt","r");
                String s=Open.readLine();
                s=new String(s.getBytes("8859_1"), "gbk");//编码转换
                System.out.println(s);
                System.out.println(Open.readLine());
    }
}

阅读(9923) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~