我已经非常努力地用以前的类似答案来解决这个问题,但我仍然无法看到我的问题,希望你能提供帮助。我的代码如下所示:
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")
最佳答案
首先,DataInputStream
中的方法 readLine()
已弃用。
其次,此方法返回一个 String
,它没有 field
length
。它只有方法length()
。 length
是数组的一个属性。
关于java - .length 无法解析或不是字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25236560/