HttpURIConnection

  • Post author:
  • Post category:其他


package com.bawei.httpuriconnection;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.Toast;

import java.io.BufferedReader;

import java.io.DataOutputStream;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.io.OutputStream;

import java.net.HttpURLConnection;

import java.net.MalformedURLException;

import java.net.URL;

public class MainActivity extends AppCompatActivity {

private Button but_huc;

private StringBuffer stringbuffer;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

initview();

but_huc.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

new Thread(new Runnable() {

@Override

public void run() {

//get请求

getservice();

//post请求

postservice();



版权声明:本文为gyingg原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。