Java Reference
In-Depth Information
{
InputStreamReader isr;
isr
=
new
InputStreamRead-
er(httpurlc.getInputStream());
BufferedReader br = new BufferedReader(isr);
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null)
sb.append(line);
System.out.println(sb.toString());
}
else
System.err.println("cannot
insert
book:
"+ht-
tpurlc.getResponseCode());
System.out.println();
}
static void doPut(String xml) throws Exception
{
URL url = new URL(LIBURI);
HttpURLConnection
httpurlc
=
(HttpURLConnection)
url.openConnection();
httpurlc.setRequestMethod("put");
httpurlc.setDoOutput(true);
httpurlc.setDoInput(true);
httpurlc.setRequestProperty("content-type",
"text/
xml");
OutputStream os = httpurlc.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os,
"utf-8");
osw.write(xml);
osw.close();
if (httpurlc.getResponseCode() == 200)
{
InputStreamReader isr;
isr
=
new
InputStreamRead-
er(httpurlc.getInputStream());
Search WWH ::




Custom Search