Java,逃避字符混乱

时间:2017-06-28 13:47:49

标签: java escaping string-formatting

我有一个简单的问题: 此代码可以工作并连接到Pro2_PGM006接入点。 如果我有字符串变量,我必须如何修改字符串“\”Pro2_PGM006 \“”???

提前谢谢你,

            config.SSID = "\"Pro2_PGM006\"";    
            config.preSharedKey = "\"*********\"";
            if (!wifiManager.isWifiEnabled()){
                wifiManager.setWifiEnabled(true);}
            wifiManager.disconnect();
                wifiManager.startScan();
            //delay(1000);
            int newId = -1;
            int tries = 0;
            while (newId == -1 && tries <=10) {
                newId = getExistingNetworkId("\"Pro2_PGM006\"");
                tries++;
            }
            if (tries >= 10) {
                Snackbar.make(view, "Cannot find WIFI", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
                fab.setBackgroundTintList(ColorStateList.valueOf(0xFFFF0000));
            }

                wifiManager.enableNetwork(newId, true);

0 个答案:

没有答案