gpt4 book ai didi

java - .length 无法解析或不是字段

转载 作者:行者123 更新时间:2023-12-01 17:06:43 27 4
gpt4 key购买 nike

我已经非常努力地用以前的类似答案来解决这个问题,但我仍然无法看到我的问题,希望你能提供帮助。我的代码如下所示:

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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com