我试图从HTTP响应中获取JSONObject.
try
{
GetMethod postMethod = new GetMethod();
postMethod.setURI(new URI(url, true));
postMethod.setRequestHeader("Accept", "application/json");
httpClient.executeMethod(postMethod);
String resp=postMethod.getResponseBodyAsString();
org.json.JSONTokener tokener = new org.json.JSONTokener(resp);
finalResult = new org.json.JSONArray(tokener);
return finalResult;
}
Run Code Online (Sandbox Code Playgroud)
但我收到了运行时警告
去缓冲大或未知大小的响应体.使用
getResponseBodyAsStream建议来代替.
我应该按照JVM的建议获得响应吗?如果是这样,我怎么能解析它的JSON?
我使用以下方法在白色空格上分割字符串
myString.split("\\s+");
Run Code Online (Sandbox Code Playgroud)
我如何为单个空间提供例外.即在空间上分开,除了单个空间
我有一个字符串"0000_Clothing | 0000_Clothing_Men's | 0000_Clothing_Men's_Shirts",我想把这个字符串拆分为"|".
String CatArray[] = CatContext.split("|");
Run Code Online (Sandbox Code Playgroud)
上面提到的代码将字符串拆分为单独的字符,如0,0,0,0,_,C,包括| 符号.
我在这里失踪了什么?