哎 今天才把这个东西给弄懂 现在终于好用了 在这 我把我的想法 来告诉大家 我们来交流交流
读文件应用示例FileInputStream inputtextfile=new FileInputStream(path);
int len=inputtextfile.available();
BufferedInputStream buffer1=new BufferedInputStre(inputtextfile);
byte bufferArray[]=new byte[len];
int n=0;
out.println("
path");
while((n=buffer1.read(bufferArray))!=-1)
{String temp=new String(bufferArray,0,n);
out.print(temp);
}
buffer1.close();
inputtextfile.close(); %>
如果是这样的话,程序就不会出现上述的问题了。开始使用的是字节流处理方法,最好用在字节输入流中加如缓冲流。一个汉字实际上是占两个字节的存储空间,在使用字节流读取或写入时,稍不注意就会出现乱码的现象。
还有比较好的办法就是使用字符流来处理。把字节流FileInputStream 对象换成字符流FileReader对象,BufferedInputStream缓冲流对象换成BufferedReader。
不过还还是谢谢斑竹 的帖子哦 感觉斑竹的一些勋章好漂亮哦`````好象是我在这里面见到勋章最多的一个了 哎 不知道我什么时候才能有象斑竹这样的勋章哦
立即注册!免费学习海量IT技术信息!!
您好!您暂时不能浏览帖子的全部内容,请登录 | 没有帐号?注册