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;
- }
- };
|