try{
RandomAccessFile file=new RandomAccessFile("e:/test.txt","r");
string line="";
while(line!=null)
{
line=file.readLine();
out.println(line);
out.println("<BR>");
RandomAccessFile file=new RandomAccessFile("e:/test.txt","r");
string line="";
while(line!=null)
{
line=file.readLine();
out.println(line);
out.println("<BR>");
你这样该的话,如果文件中间有一段空白,程序就不读后面的文字了,例如
For information on deployment licenses, see our sales page. You may use Resin for development, evaluation, and demos.
后面的一句程序就不读了
RandomAccessFile file=new RandomAccessFile("e:/test.txt","r");
String line=file.readLine();
while(line!=null)
{
out.println(line);
out.println("<BR>");
}
}
{
String line=file.readLine();
if (line == null) break;
out.println(line);
out.println("<BR>");}
or:String line = "";
while(line != null)
{
line=file.readLine();
out.println(line);
out.println("<BR>");}
{
fff =new RandomAccessFile("e:/test.txt","r");
filesize = fff.length();
System.out.println("File size :"+ filesize);
while ( filesize > filepointer)
{
filepointer = fff.getFilePointer();
sss = fff.readLine();
System.out.println("filepointer : "+filepointer+" "+sss);
}
fff.close();
}
同意kellychen(陈慧琳)
另外你也可以用getFilePointer来判断