标题:
JAVA流操作(2)文件流
[打印本页]
作者:
look_w
时间:
2017-11-18 20:25
标题:
JAVA流操作(2)文件流
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;
}
};
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/)
Powered by Discuz! 7.0.0