请问一个笔试题和一个基础有关问题:)

请教一个笔试题和一个基础问题:)
题(   ):   1.   一个文本文件有多行,每行为一个URL。请编写代码,统计出URL中的文件名及出现次数。  
a)文件名不包括域名、路径和URL参数,例如http://www.rs.com/n.op/q/rs?id=1中的文件名是rs。  
b)部分URL可能没有文件名,例如http://www.abc.com/,这类统计为“空文件名”。  
c)出现在不同URL中的相同文件名视为同一文件名,例如http://www.ceshi.com/hi.php  
和ftp://ftp.cdef.com/hi.php为同一文件名  

文件内容示例如下:  
http://www.test.com/abc/de/fg.php?id=1&url=http://www.test.com/index.html  
http://www.ceshi.com/hi.jsp  
ftp://ftp.ceshi.com/hi.jsp  
http://www.hello.com/cw/hi.jsp?k=8  
http://www.hi.com/jk/l.html?id=1&s=a.html  
http://www.rs.com/n.op/q/rs?id=1  
http://www.abc.com/  

/**以下是我写的方法因为确实太累赘但想不出别的方法,如果您有好的方法请指教指教~谢谢   **/

//   读入题目所给出的字符    
import   java.io.*;
public   class   FileStream{
private   String   str= " ";  
String   result= " ";
public   void   returnStr   (){
Fenjie   fj=new   Fenjie(); //分解处理字符串的类

File   f   =   new   File( "e:\\hello.txt ");   //文件内容就是题目所给的7行URL地址
try
{
BufferedReader   br=new   BufferedReader(   new   FileReader(f)   );
while((result=br.readLine())!=null   ){

fj.aA(result); //在这里处理字符串
}  
fj.display();   //打印处理结果
}  
catch   (Exception   e) {System.out.println(e.getMessage());}
}
}   //   End   FileStream   class  


class   Fenjie  
{
String   str= " ";
int   d=0,h=0,count=0;
String   newstr= " ";
String   []string=   new   String[20];

public   void   aA(String   s){     //提取每一行最后一个 "/ "与 ". "之间的字符串
str=s;  
String   []x   =   new   String[str.length()];
h   =   str.lastIndexOf( "/ ");
        d   =   str.lastIndexOf( ". ");

if   (h> d)   //   个别以 "? "结尾的文件名,如 "   rs?id=1   "
d   =   str.lastIndexOf( "? ");        
if   (   h   >   d)   //   如果是空文件名
d=h+1;    
newstr=   str.substring(h+1,d);  
int   ii=newstr.lastIndexOf( ". ");
if(   ii   >   0   )
newstr=newstr.substring(0,ii);
string[count]=newstr;

if(string[count].equals( " "))   //   判别空文件名
string[count]= "空文件名 ";
count++;
}
//   声明新的数组,打印不是 "重复出现 "的数组.
public   void   display(){  
int   []   w   =   new   int   [count];
for(int   i=0;i <count;i++)
w[i]=1;

for(int   i=0   ;   i <   count   ;   i++   )
for(int   k=i+1;k <count-1;k++)      
    if(   string[i].equals(string[k])   ) {    
    string[k]= "重复出现 ";
            ++w[i];    
                    }

for(int   i=0   ;i <count;i++   )
if(string[i]   !=   "重复出现 ")
System.out.printf( "%-10s     出现了     %10d   次\n ",string[i],w[i]);