我想替换一个字符串表达式,并收到以下错误消息:
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);
}
}这是更新的代码,我可以看到我的字符串错误在哪里
发布于 2016-02-15 03:42:36
使用StringUtil.replaceAll(字符串,模式,替换)。
在VM层中实现这一点要困难得多,要以一种真正可移植的方式来实现,所以我们建议您使用更可移植的版本。
发布于 2016-02-15 10:58:02
在编写代码时,netbean中不会出现任何错误,而且它会显示运行时错误,因此应该导入StringUtil并将其称为replaceAll静态方法(例如: StringUtil.replaceAll )。
https://stackoverflow.com/questions/35400749
复制相似问题