我用以前的类似答案努力解决这个问题,但我仍然无法看到我的问题,希望你能提供帮助。我的代码如下所示:
String MyContent =" ";
String nextline = " ";
InputStream in = new FileInputStream(f);
BufferedInputStream bin = new BufferedInputStream(in);
DataInputStream din = new DataInputStream(bin);
while(din.available()>1)
{
nextline = din.readLine();
//Filter out XML headers which are not browser compliant
if (nextline.length > 4)
{
if (nextline.substring(1,5) != "<?xml")
{
MyContent=MyContent+ nextline;
}
}
}
out.print (MyContent);
in.close();
bin.close();
din.close();
我收到了一个错误:
An error occurred at line: 25 in the jsp file: /MaxiSunReports/DisplayXMLFile.jsp
nextline.length cannot be resolved or is not a field
22: nextline = din.readLine();
23: nextline = "THISISATEST";
24: //Filter out XML headers which are not browser compliant
25: if (nextline.length > 4)
26: {
27: if (nextline.substring(1,5) != "<?xml")
答案 0 :(得分:5)
首先,readLine()
中的方法DataInputStream
已弃用。
其次,此方法返回String
,其中没有field
length
。它只有方法length()
。 length
是数组的属性。
答案 1 :(得分:0)
length
不是字段。这是一个功能,因此您必须致电nextline.length() > 4
答案 2 :(得分:0)
长度不是属性,它是一种方法..
使用
while(din.available()>1)
{
nextline = din.readLine();
//Filter out XML headers which are not browser compliant
if (nextline.length() > 4)
{
if (nextline.substring(1,5) != "<?xml")
{
MyContent=MyContent+ nextline;
}
}
}