SDK中关于HttpURLConnection.setDoInput(true)和HttpURLConnection.setDoOutput(true)的描述

来源:互联网 发布:神奇的印度人 知乎 编辑:程序博客网 时间:2024/06/06 04:59

直接看SDK java.net.URLConnection

  • java.lang.Object
    • java.net.URLConnection
      • java.net.HttpURLConnection

  • setDoInput

    public void setDoInput(boolean doinput)
    Sets the value of the doInput field for this URLConnection to the specified value.

    A URL connection can be used for input and/or output. Set the DoInput flag to true if you intend to use the URL connection for input, false if not. The default is true.

    Parameters:
    doinput - the new value.
    Throws:
    IllegalStateException - if already connected
    See Also:
    doInput,getDoInput()
  • setDoOutput

    public void setDoOutput(boolean dooutput)
    Sets the value of the doOutput field for this URLConnection to the specified value.

    A URL connection can be used for input and/or output. Set the DoOutput flag to true if you intend to use the URL connection for output, false if not. The default is false.

    Parameters:
    dooutput - the new value.
    Throws:
    IllegalStateException - if already connected
    See Also:
    getDoOutput()
合起来翻译一下就是,一个URL连接可以用来输入或输出。
setDoInput(boolean doinput)如果你打算输入,则设置为ture,否则false。默认true
setDoOutput(boolean dooutput)如果你打算输出,则设置为true,否则false。默认false

阅读全文
0 0
原创粉丝点击