3-65
User Guide for Resource Manager Essentials 4.1
OL-11714-01
Chapter 3 Adding and Troubleshooting Devices Using Device Management
Device List Manipulation Service
url = new URL ("http://" + Host +URI);
} else {
url = new URL ("http", Host, Port, URI);
}
urlConn = url.openConnection();
urlConn.setDoInput (true);
urlConn.setDoOutput (true);
urlConn.setUseCaches (false);
urlConn.setDefaultUseCaches (false);
urlConn.setRequestProperty
("Content-Type", "application/x-www-form-urlencoded");
printout = new DataOutputStream (urlConn.getOutputStream ());
if (data != null)
printout.writeBytes(data);
printout.flush();
printout.close();
return new DataInputStream (new BufferedInputStream( urlConn.getInputStream ()));
}catch (Exception e) {
pw.println("Error in execPOST: "+ e.getMessage());
return null;
}
}
private String fileToString (String filename, PrintWriter pw) {
InputStream is = null;
String out = "";
try {
is = new FileInputStream(filename);
} catch (FileNotFoundException notFound) {
pw.println("Error in fileToString: " + notFound.getMessage());
return null;
}
if (is == null) pw.println("read nothing from the file");
else pw.println("read ok from the xml file.");
try {
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while((line = br.readLine()) != null) {