我已经尝试过很难用之前的类似答案来解决这个问题,但我仍然无法看到我的问题,希望你能提供帮助.我的代码看起来像这样:
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();
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
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")
Run Code Online (Sandbox Code Playgroud)
首先,该方法readLine()中DataInputStream已过时.
其次,这个方法返回一个String,它没有field length.它只有方法length().length是数组的属性.
| 归档时间: |
|
| 查看次数: |
10347 次 |
| 最近记录: |