0
當我試圖做一個String.ReplaceAll時,我得到了一個patternsyntax異常。PatternSyntaxException:在Java中使用String.ReplaceAll函數?
下面是我的字符串
Number of testcases to execute : 39? Starting execution of test case : testCreateDAta? The class that has completed its execution is : test.com.mySpace.service.ejb.session.MyTest? Finished execution of test case : testCreateDAta? Starting execution of test case : testUpdate?
我試圖做的事:
junitReportString.replaceAll("?", "\n");
上面的代碼獲取我下面的例外:
java.util.regex.PatternSyntaxException: Dangling meta character '?' near index 0
然後我試圖再次使用以下代碼:
junitReportString.replaceAll("\\?", "\n");
上面的代碼提取了我與上面提到的相同的字符串。
我的完整編號:
String junitReportString=new String();
myApp= new URL("http://localhost:port/testWeb/TestJunit.jsp");
URLConnection yc = myApp.openConnection();
yc.connect();
junitReportString=yc.getHeaderField("finalJUNITReport").toString();
System.out.println(junitReportString);
junitReportString.replaceAll("\\?", "\n");
System.out.println("Report Details ==============>"+junitReportString);
什麼是錯我的代碼。任何指導非常感謝。
你的代碼'的replaceAll( 「\\?」, 「\ n」);'對我的作品.. – 2014-10-10 06:48:20
我無法打印字符串中的新行。 ( – sTg 2014-10-10 06:49:39
你能發佈你的完整代碼嗎? – 2014-10-10 06:50:38