cURLをAndroidのHttpUrlConnectionに読み替え

#cURLをまずよく知らない
そのため、curlで書いたコマンドを移植しようと際に困ったのでメモ

#HttpUrlConnection
- Androidで動くサンプル

```java:sample.java

package com.example.***;

import android.os.AsyncTask;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;


public class MainActivity extends AppCompatActivity {
    TextView textview;
    class HttpGetTask extends AsyncTask<URL, Void, String> {

        @Override
        protected String doInBackground(URL... url) {
            String result = "";
            HttpURLConnection conn = null;
            try {
                conn = (HttpURLConnection) url[0].openConnection();
                conn.setReadTimeout(10000);
                conn.setConnectTimeout(15000);
                conn.setRequestMethod("GET");
                conn.setRequestProperty("Referer", "https://hogehoge");       conn.setDoInput(true);
                conn.connect();
                int resp = conn.getResponseCode();
                result = readIt(conn.getInputStream());
            } catch(IOException e) {
                e.printStackTrace();
            } finally {
                if(conn != null) {
                    conn.disconnect();
                }
            }
            return result;
        }

        public String readIt(InputStream stream) throws IOException, UnsupportedEncodingException {
            StringBuffer sb = new StringBuffer();
            String line = "";
            BufferedReader br = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
            while((line = br.readLine()) != null){
                sb.append(line);
            }
            try {
                stream.close();
            } catch(Exception e) {
                e.printStackTrace();
            }
            return sb.toString();
        }

        @Override
        protected void onPostExecute(String response) {

            textview.setText(response);
        }
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        textview = (TextView)findViewById(R.id.tv1);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String ret = test();
            }

        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }


    public String test(){
        String ret=  null;

        URL url = null;
        try {
            url = new URL("http://192.168.0.10");
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }

        new HttpGetTask().execute(url);

        return ret;
    }

}


```