简体   繁体   中英

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

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

Use 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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