简体   繁体   English

错误:找不到符号(使用replaceAll)codenameone

[英]error: cannot find symbol (using replaceAll ) codenameone

I´m want to replace a String expression and I receive this error message 我想替换一个字符串表达式,并且收到此错误消息

    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

this is my code 这是我的代码

    String testw= String.valueOf(element1);


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

I use Netbeans 8.1 我使用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)

The complete code updated 完整的代码已更新

 @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);
}
 }

That's the code updated, I can see where is my mistake with the String 那是更新的代码,我可以看到我的String错误在哪里

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

Implementing this in the VM layer is much harder to do in a truly portable way and so we nudge you towards the more portable versions. 要真正以可移植的方式在VM层中实现此任务要困难得多,因此我们将向轻巧的版本过渡。

netbean编码时不会有任何错误,并且会显示运行时错误,因此应导入StringUtil并将其称为replaceAll静态方法,例如:StringUtil.replaceAll

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM