//Get Response
InputStream is = connection.getInputStream();
// FileUtils.writeByteArrayToFile(new File("\\responseFairview.binary"), IOUtils.toByteArray(is));
UtilsFlexMessage utilsFlex = new UtilsFlexMessage();
utilsFlex.parseInputStream(is);
//Get pickupItem
String content = utilsFlex.messageToXML();
System.out.println(content);
String pickupItem = "pickup_item:" + StringUtils.substringBetween(content, "<string>pickup_item:", "</string>");
System.out.println(pickupItem);
String oldPickupItem = "pickup_item:276698290864898721:917:dn34ppe0ireh";
//Get template pickupItemMoney and update with new item get above
theFile = FileUtils.readFileToByteArray(docSerializeMoney);
ByteArrayInputStream bais = new ByteArrayInputStream(theFile);
DataInputStream din = new DataInputStream(bais);
utilsFlex = new UtilsFlexMessage();
utilsFlex.parseInputStream(din);
String update = utilsFlex.updateFlexMessage(oldPickupItem, pickupItem);
byte[] newdataPickupItem = utilsFlex.serializeMessage(update);
//new Connection to pickup Money
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Connection", "keep-alive");
connection.setRequestProperty("Content-Type", contentType);
// connection.setRequestProperty("Content-Length", "" + xurro.length);
// connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
//Send request
wr = new DataOutputStream(connection.getOutputStream());
wr.write(newdataPickupItem);
wr.flush();
wr.close();
System.out.println("responsecode:" + connection.getResponseCode());
//Get template pickupItemCollection and update with new item get above
int temp = StringUtils.indexOf(content, "<string>collection_loot_item_id</string>\n <null/>");
System.out.println(temp);
if (temp != -1) {
theFile = FileUtils.readFileToByteArray(docSerializeCollection);
bais = new ByteArrayInputStream(theFile);
din = new DataInputStream(bais);
utilsFlex = new UtilsFlexMessage();
utilsFlex.parseInputStream(din);
update = utilsFlex.updateFlexMessage(oldPickupItem, pickupItem);
newdataPickupItem = utilsFlex.serializeMessage(update);
//new Connection to pickup ItemCollection
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Connection", "keep-alive");
connection.setRequestProperty("Content-Type", contentType);