问题是:
TelNumStore.java:21:cannot find symbol
symbol :class FindLine
location:class TelNumStore
import java.io.*;
import java.util.*;public class TelNumStore 
{
//private Collection c1,c2;
private Collection[] files;
private static final String STR = "LT:90";
private HashSet<String> telNumSet;
private String AR;//specify the AR

public TelNumStore(String f[],String ar)
{
files = new Collection[f.length];
telNumSet = new HashSet<String>();
//c1 = new FindLine(file1).find();
//c2 = new FindLine(file2).find();
for(int i=0; i<files.length; i++)
{
f[i] = fileSuffixCheck(f[i],".txt");
files[i] = new FindLine(f[i]).find();
}
AR = ar;
}

public void storeTelnum(String file)
{
FileOutputStream fos=null;
file = fileSuffixCheck(file,".txt");
try
{
fos = new FileOutputStream(new File(".\\"+file));
}
catch(IOException e)
{
e.printStackTrace();
}

//findTelNum(c1);
//findTelNum(c2);
for(int i=0; i<files.length; i++)
{
findTelNum(files[i],AR);
}


System.out.println(telNumSet);
Iterator it = telNumSet.iterator();
while(it.hasNext())
{
String str = (String)it.next();
try
{
fos.write(str.getBytes(),0,str.getBytes().length);
fos.write((byte)'\t');
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

public void findTelNum(Collection c,String ar)
{
Iterator it = c.iterator();
String maybe = null;
boolean matchAR = false;

while(it.hasNext())
{
StringTokenizer st = new StringTokenizer((String)it.next()," ");
while(st.hasMoreTokens())
{
String str = st.nextToken();
if(str.contains("PN:"))
{
//telNumSet.add(str);
maybe = str;
}
if( str.contains("AR:"+ar))
matchAR = true;
}
}
if(matchAR)
telNumSet.add(maybe);
}

private String fileSuffixCheck(String fileName,String suf)
{
if(fileName.lastIndexOf(suf)==-1)
return fileName+suf;
return fileName;
}

//--------------------------------------
public static void main(String args[])
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int fileNum=0;
String files[]=null;
String fileStore=null;
String AR = null;

System.out.print("输入的日期: ");
try
{
fileNum = Integer.parseInt(br.readLine());
files = new String[fileNum];
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("exiting...");
System.exit(0);
}

for(int i=0; i<fileNum; i++)
{
System.out.print("file"+i+": ");
try
{
files[i] = br.readLine();
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("exiting...");
System.exit(0);
}
}

System.out.print("存储的文件名: ");
try{
fileStore = br.readLine();
}
catch(Exception e)
{
e.printStackTrace();
}

System.out.print("AR: ");
try
{
AR = br.readLine();
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
try
{
br.close();
}
catch(IOException e)
{
e.printStackTrace();
}
}

new TelNumStore(files,AR).storeTelnum(fileStore);
}
}

解决方案 »

  1.   

    //不是早就给你了,FindLine这个类
    import java.io.*;
    import java.util.*;public class FindLine {
    private File file;
    private static final String TOFIND = "LT:90";
    private Collection <String>result;

    /**
     * constructor
     * @param fpath the specified file (path)name
     */
    public FindLine(String fpath){
    file = new File(fpath);
    result = new ArrayList<String>();
    }


    /**
     * perform the function of finding the line which containing the specified
     * string
     * @param str the specified string contained in the line
     * @return the line that contains the specified str
     *  or null,if no line contains such string
     */
    public Collection find(String str){
    try{
    BufferedReader br = new BufferedReader(new FileReader(file));
    String tmp = new String();
    while((tmp=br.readLine())!=null){
    if(tmp.contains(str)){
    //return tmp;
    result.add(tmp);
    }
    }
    }catch(IOException e){
    e.printStackTrace();
    }

    return result;
    }


    /**
     * performed the find function,the specified string is initialized to
     * "LT:90"
     * @return the line that contains the specified str
     *  or null,if no line contains such string
     */
    public Collection find(){
    return find(TOFIND);
    }

    /**
     * the main function
     * @param args ...
     */
    public static void main(String[] args){
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String name = new String();
    System.out.print("intput the file name: ");
    try{
    name = br.readLine();
    if(name.lastIndexOf(".txt")==-1){
    name += ".txt";
    }
    }catch(IOException e){
    e.printStackTrace();
    System.exit(1);
    }

    System.out.println(new FindLine(".\\"+name).find());
    }


    }
      

  2.   

    看提示啊
    已经写了,cannot find symbol  没有找到类
    FindLine肯定是在files[i] = new FindLine(f[i]).find();  没有找到类
      

  3.   

    to believefym(feng) : 好佩服你哦,关于程序的帖子,你解决了很多耶,高手!!!
      

  4.   

    正在看thinking in java,暑假没事就写写了--------------------------楼主好像从不结贴的,我回了他那么多帖子都还没拿到分呢