Code example for HttpURLConnection

Methods: getInputStream, getOutputStream, setDoInput, setDoOutput, setRequestMethod, setUseCaches

0
		try { 
			URL eveOnlineURL = null;
			HttpURLConnection myConnection = null;
			eveOnlineURL = new URL("http://api.eve-online.com/char/SkillInTraining.xml.aspx");
			myConnection = (HttpURLConnection) eveOnlineURL.openConnection();
			myConnection.setRequestMethod("POST");
			String data = "userid=" + inAccountDetails.getUserID() + "&apikey=" + inAccountDetails.getPublicAPIKey() + "&characterid=" + inCharacterID;
			myConnection.setUseCaches(false);
			myConnection.setDoInput(true);
			myConnection.setDoOutput(true);
			DataOutputStream os = new DataOutputStream(myConnection.getOutputStream());
			os.writeBytes(data);
			os.flush();
			os.close();
			 
			DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
			try { 
				DocumentBuilder db = dbf.newDocumentBuilder();
				db.reset();
				try { 
					SAXParserFactory spf = SAXParserFactory.newInstance();
					SAXParser sp = spf.newSAXParser();
					XMLReader reader = sp.getXMLReader();
					SkillInTrainingEventHandler handler = new SkillInTrainingEventHandler();
					reader.setContentHandler(handler);
					InputSource is = null;
					if (!GGEveApplicationRunner.getIsRunningOffline()) 
					{is = new InputSource(myConnection.getInputStream());}
					else 
					{is = new InputSource(GGEveApplicationRunner.getGGEveOfflineCharacters());}
					reader.parse(is);
					myTrainingInformation = handler.getTrainingInformation();