InputStream getInputStream(); 方法不好用了???
importjava.io.BufferedReader;importjava.io.IOException;importjava.io.InputStream;impo...
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
其中的方法
public String fetchBookInfoByXML(String isbnNo) throws IOException {
String requestUrl = isbnUrl + isbnNo + "?apikey=" + apikey;
URL url = new URL(requestUrl);
URLConnection conn = url.openConnection();
InputStream is = conn.getInputStream();
InputStreamReader isr = new InputStreamReader(is, "utf-8");
BufferedReader br = new BufferedReader(isr);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = br.readLine()) != null) {
sb.append(line);
}
br.close();
return sb.toString();
}
InputStream getInputStream(); 方法不好用了???没反应了,不知道为什么??
请大家赐教 展开
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
其中的方法
public String fetchBookInfoByXML(String isbnNo) throws IOException {
String requestUrl = isbnUrl + isbnNo + "?apikey=" + apikey;
URL url = new URL(requestUrl);
URLConnection conn = url.openConnection();
InputStream is = conn.getInputStream();
InputStreamReader isr = new InputStreamReader(is, "utf-8");
BufferedReader br = new BufferedReader(isr);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = br.readLine()) != null) {
sb.append(line);
}
br.close();
return sb.toString();
}
InputStream getInputStream(); 方法不好用了???没反应了,不知道为什么??
请大家赐教 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询