日期:2014-05-20  浏览次数:21190 次

java编译的时候说找不到符号?
做一个jsp的在线做题页面。
没学过java,就照着书上的敲了,结果说找不到符号,怎样解决啊?
代码如下:
package small.dog;
import java.io.*;
public class test
{
String filiname="";
String correctAnswer="";
String testContent="";
String selection="";
int score=0;
boolean pifend=false;
File f=null;
FileReader in=null;
BufferedReader buffer=null;
public void setFilename(String name)
{
filename=name;
score=0;
selection="";
pifend=false;
try
{
f=new File("e:/",filename);
in=new FileReader(f);
buffer=new BufferedReader(in);
correctAnswer=(buffer.readLine()).trim();
}
catch(Exception e)
{
testContent="没有选择试卷";
buffer=null;
}
}
public String getFilename()
{
return filename;
}
public String getTestContent()
{
try
{
String s=null;
StringBuffer temp=new StringBuffer();
if(buffer!=null)
{
while((s=buffer.readLine())!=null)
{
if(s.startsWith("**"))
break;
s=getString(s+"\n");
temp.append(s);
if(s.startsWith("endend"))
{
in.close();
buffer.close();
}
testContent=new String(temp);

}
}
else
{
testContent=new String("没有选择试题");
}
}
catch(Exception e)
{
testContent="试题无内容,考试结束";
try
{
in.close();
buffer.close();
}
catch(IOException exp)
{
}
}
return testContent;
}
public void setSelection(String s)
{
selection=selection+s;
}
public int getScore()
{
int length1=selection.length();
int length2=correctAnswer.length();
int i=length1-1;
if((i!=-1)&&(i<=length2-1))
{
if((selection.charAt(i)==correctAnswer.charAt(i))&&(pifend==false))
{
score++;
}
if(i==length2-1)
{
pifend=true;
}
}
return score;
}
public String getString(String content)
{
try
{
StringReader in=new StringReader(content);
PushbackReader push=new PushbackReader(in);
StringBuffer stringbuffer=new StringBuffer();
int c;
char b[]=new char[1];
while((c=push.read(b,0,1))!=-1)
{
String s=new String(b);
if(s.equals("<"))
{
push.unread('&');
push.read(b,0,1);
stringbuffer.append(new String(b));
push.unread('L');
push.read(b,0,1);
stringbuffer.append(new String(b));
push.unread('T');
push.read(b,0,1);
stringbuffer.append(new String(b));
}
else if(s.equals(">"))
{
push.unread('&');
push.read(b,0,1);
stringbuffer.append(new String(b));
push.unread('G');
push.read(b,0,1);
stringbuffer.append(new String(b));
push.unread('T');
push.read(b,0,1);
stringbuffer.append(new String(b));
}
else if(s.equals("\n"))
{
stringbuffer.append("<br>");
}
else
{
stringbuffer.append(s);
}
}
push.close();
in.close();
return (new String(stringbuffer));
}
catch(IOException e)
{
return content=new String("不能读取内容");
}
}
}

编译时的提示:
test.java:16: 找不到符号
符号: 变量 filename
位置: 类 small.dog.test
  filename=name;
  ^
test.java:22: 找不到符号
符号: 变量 filename
位置: 类 small.dog.test
  f=new File("e:/",filename);
  ^
test.java:35: 找不到符号
符号: 变量 filename
位置: 类 small.dog.test
return filename;
  ^
3 错误

------解决方案--------------------