JAVA流操作(2)文件流

来源:互联网 发布:编程资料 编辑:程序博客网 时间:2024/05/19 18:13

File f = new File("test.txt");

//构建文件对象

RandomAccessFile f = new RandomAccessFile("Hello.txt","rw");
//构建随机访问文件对象

FileOutputStream fout = new FileOutputStream(f);
//文件输出流,数据从流中写入文件

FileInputStream fout = new FileInputStream(f);
//文件输入流,数据从文件中写入流



附一个中文出现乱码的解决方案:

public static String parseChinese(String inStr) { String s = null; byte temp[]; if (inStr == null) { return new String(""); } try { temp=inStr.getBytes("iso-8859-1"); s = new String(temp); } catch(UnsupportedEncodingException e) { System.out.println (e.toString()); } return s;        } };

1 0
原创粉丝点击