***************************************************************************************
这里我采取的方法是 1:首先使用一个流读取文件计算出该文件一共有多少行
2:然后再用第二个流读出最后一行的字符
要注意的是要 创建2个输入流
qq:83529101
*************************************************************************************
package charl;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class PrintLL
{
private static int count;
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
File src =new File("c:/my.txt");
FileReader fr =null;
FileReader fr1 =null;
BufferedReader br =null;
BufferedReader br1 =null;
try
{
fr =new FileReader(src);
fr1=new FileReader(src);
br =new BufferedReader(fr);
br1=new BufferedReader(fr1);
} catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
System.out.println("FileNotFound");
}
try {
while((br.readLine())!=null)
{
count++;
}
} catch (IOException e)
{
// TODO Auto-generated catch block
System.out.println("IO Err");
}
System.out.println("文件总行数:"+count);
try {
//System.out.println("begin..");
int i=0;
String buf=null;
while((buf=br1.readLine())!=null)
{
// System.out.println("ok");
i++;
// System.out.println(i);
if(i==count-1)
System.out.println("最后一行的内容是:"+buf);
}
} catch (IOException e)
{
// TODO Auto-generated catch block
System.out.println("IO Err");
}
System.out.println("end..");
}
}