当前位置: 技术问答>java相关
jsp中对文件操作,怎样判断是否已到文件尾?
来源: 互联网 发布时间:2015-02-02
本文导语: 文本文件中有多行文本,每次取出一行显示,怎样判断是否已到文件尾? | RandomAccessFile raf = new RandomAccessFile(file,mode); long filepointer = 0; long filesize = 0; byte [] in; int filesize = raf.l...
文本文件中有多行文本,每次取出一行显示,怎样判断是否已到文件尾?
|
RandomAccessFile raf = new RandomAccessFile(file,mode);
long filepointer = 0;
long filesize = 0;
byte [] in;
int filesize = raf.length();
System.out.println("File size :"+ filesize);
while ( filesize > filepointer)
{
filepointer = raf.getFilePointer();
String line = new String(raf.readLine());
}
raf.close();
long filepointer = 0;
long filesize = 0;
byte [] in;
int filesize = raf.length();
System.out.println("File size :"+ filesize);
while ( filesize > filepointer)
{
filepointer = raf.getFilePointer();
String line = new String(raf.readLine());
}
raf.close();
|
while (in.available()!=0)
{
...
}
{
...
}