Code example for DataOutputStream

Methods: close, flush, writeBytes

0
				connection.setRequestProperty("charset", "utf-8");
				connection.setRequestProperty("Content-Length", "" + Integer.toString(dataString.getBytes().length));
				connection.setUseCaches (false);
				 
				//Output the data 
				DataOutputStream wr = new DataOutputStream(connection.getOutputStream ());//IOException
				wr.writeBytes(dataString);//IOException
				wr.flush();//IOException
				wr.close();//IOException
				 
				//TODO: Make the server actually got data 
					//http://docs.oracle.com/javase/1.5.0/docs/api/java/net/HttpURLConnection.html 
				 
				connection.disconnect();
			} catch(MalformedURLException mue) {
				System.out.println("Problem creating the url object.");
				mue.printStackTrace();
				writeToLocalDB(1, data);
			} catch(ProtocolException pe){
				System.out.println("Problem with chosen protocol.");
				pe.printStackTrace();