Code example for DataOutputStream

Methods: close, flush, write

0
			urlConnect.setUseCaches(false); //post请求不能使用缓存
			urlConnect.setRequestMethod("POST");  //设置post方式请求
			urlConnect.setInstanceFollowRedirects(true); 
			urlConnect.setRequestProperty("Content-Type","application/x-www-form-urlencode");// 配置请求Content-Type
			urlConnect.connect();  // 开始连接
			DataOutputStream dos = new DataOutputStream(urlConnect.getOutputStream()); // 发送请求参数
			dos.write(postData);
			dos.flush();
			dos.close();
			if (urlConnect.getResponseCode() == 200) {    //请求成功
				byte[] data = readInputStream(urlConnect.getInputStream());   
				 
    			Intent httpclientIntent = new Intent();
    			httpclientIntent.putExtra("content", new String(data, "UTF-8"));
    			httpclientIntent.setClass(getApplicationContext(), detailActivity.class);
    			startActivity(httpclientIntent);
 
			} 
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();