出现了错误
package xi;import java.io.*;
public class Xigust{
public void setstr(String filename,String str){
try{
RandomAccessFile a = new RandomAccessFile(filename,"rw");
long f = a.length();
long f1 = 0;
if(f==f1){
File newfile = new File(filename);
a = new RandomAccessFile(newfile,"rw");
a.writeBytes(str);
}
else{String oldstr = null;
while(f1<f){
oldstr = oldstr+ a.readLine();
f1 = a.getFilePointer();
}
/*str = str + oldstr;*/
a.writeBytes(str);
}
}
catch (IOException e1) {
e1.printStackTrace();
}
}
public String getxifile(String filename){//getxifile方法
String m = "<br/>";
try{
RandomAccessFile a = new RandomAccessFile(filename,"rw");
long f = a.length();
long f1 = 0;
if(f==f1){
return m;
}
else{
String oldstr = null;
while(f1<f){
oldstr = oldstr+ a.readLine();
f1 = a.getFilePointer();
}
m = oldstr;
return m;
}
}
catch(IOException e1){
e1.getMessage();
}
return m;
}
public static void main(String[] args){
Xigust s = new Xigust();
String d=s.getxifile("F:\\www\\xi\\txt\\b.txt");
System.out.print(d);//这里没有问题,可以正常out。print
}
}
下面是一个JSP
<%@ page import="xi.*,java.io.*"%>
<%
Xigust yuxi =new Xigust();
String path="F:\\www\\xi\\txt\\b.txt";
out.println(yuxi.getxifile(path));%>//这里就有问题了,怎么办?