gpt4 book ai didi

java - 错误 : cannot find symbol (using replaceAll ) codenameone

转载 作者:行者123 更新时间:2023-11-30 08:04:44 28 4
gpt4 key购买 nike

我想替换一个字符串表达式,但我收到了这条错误消息

    error: cannot find symbol
test1 = testw.replaceAll("/uploads","http://www.anbariloche.com.ar/uploads");
symbol: method replaceAll(String,String)
location: variable testw of type String

这是我的代码

    String testw= String.valueOf(element1);


String test1;
test1 = testw.replaceAll("/uploads","http://www.anbariloche.com.ar/uploads");

我使用 Netbeans 8.1

Product Version: NetBeans IDE 8.1 (Build 201510222201)
Java: 1.7.0_79; Java HotSpot(TM) Client VM 24.79-b02
Runtime: Java(TM) SE Runtime Environment 1.7.0_79-b15
System: Windows 7 version 6.1 running on x86; Cp1252; es_ES (nb)

完整代码已更新

 @Override
protected void beforePortada(Form f) {
WebBrowser browser=new WebBrowser();
f.setLayout(new BorderLayout());
f.addComponent(BorderLayout.CENTER, browser);

/////Parse
String URL= "http://www.anbariloche.com.ar/";

ConnectionRequest req = new ConnectionRequest();
req.setUrl(URL);
NetworkManager.getInstance().addToQueueAndWait(req);
byte[] data = req.getResponseData();
if (data == null) {

}



XMLParser xmlParser=new XMLParser();
Element element= null;
try {
element = xmlParser.parse(new InputStreamReader(new ByteArrayInputStream(data), "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Element element1=element.getChildAt(0);


String testw= String.valueOf(element1);
///replace the string
testw = testw.replaceAll("/uploads/","http://www.anbariloche.com.ar/uploads/");

browser.setPage(testw,null);
}
}

那是更新的代码,我可以看到我的错误在哪里用字符串

最佳答案

使用StringUtil.replaceAll(string, pattern, replace) .

以真正可移植的方式在 VM 层中实现这一点要困难得多,因此我们建议您使用更可移植的版本。

关于java - 错误 : cannot find symbol (using replaceAll ) codenameone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35400749/

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