• 2021 5 13


    访问自己的阿里云服务器挂的servlet:

    package com.michael.cloudphotos;
    
    import android.os.Message;
    import android.util.Log;
    
    import java.io.BufferedInputStream;
    import java.io.BufferedReader;
    import java.io.DataInputStream;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.HttpURLConnection;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.net.URLConnection;
    import android.os.Handler;
    
    public class gethttp extends Thread {
        public String m_url;
        public Handler handler;
        public gethttp(String url, Handler handler) {
            this.m_url=url;
            this.handler=handler;
        }
        @Override
        public void run() {
            HttpURLConnection connection=null;
            try {
                URL url=new URL(m_url);
                connection=(HttpURLConnection) url.openConnection();
                connection.connect();
                String lines=null;
    //            BufferedReader br=new BufferedReader(new InputStreamReader(connection.getInputStream()));
                DataInputStream ios=new DataInputStream(new DataInputStream(connection.getInputStream()));
                lines=ios.readUTF();
                Log.i("info:",lines);
                Message msg=new Message();
                msg.what=1;
                msg.obj=lines;
                handler.sendMessage(msg);
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }finally {
                if(connection!=null)
                {
                    connection.disconnect();
                }
            }
        }
    }
  • 相关阅读:
    TypeScript Handbook 2——接口1(翻译)
    TypeScript Handbook 1——基本类型(翻译)
    [转]AJAX 跨源 HTTP 请求
    [转] Delphi Socket Architecture
    handsontable的一种js继承方式
    test11
    test
    javascript代码风格
    maven创建web项目
    Oracle 11g R2 for Win10(64位)的安装注意点
  • 原文地址:https://www.cnblogs.com/fuxw4971/p/14910502.html
Copyright © 2020-2023  润新知