| 方法 | 描述 |
|---|
| void addRequestProperty(String key, String value) | 它添加由键值对指定的通用请求属性 |
| void connect() | 如果尚未建立连接,它会打开与此 URL 引用资源的通信链接。 |
| boolean getAllowUserInteraction() | 它返回对象的 allowUserInteraction 字段的值。 |
| int getConnectionTimeout() | 它返回连接超时设置。 |
| Object getContent() | 它检索 URL 连接的内容。 |
| Object getContent(Class[] classes) | 它检索 URL 连接的内容。 |
| String getContentEncoding() | 它返回 content-encoding 头部字段的值。 |
| int getContentLength() | 它返回 content-length 头部字段的值。 |
| long getContentLengthLong() | 它将 content-length 头部字段的值作为 long 返回。 |
| String getContentType() | 它返回 date 头部字段的值。 |
| long getDate() | 它返回 date 头部字段的值。 |
| static boolean getDefaultAllowUserInteraction() | 它返回 allowUserInteraction 字段的默认值。 |
| boolean getDefaultUseCaches() | 它返回 URLConnection 的 useCaches 标志的默认值。 |
| boolean getDoInput() | 它返回 URLConnection 的 doInput 标志的值。 |
| boolean getDoInput() | 它返回 URLConnection 的 doOutput 标志的值。 |
| long getExpiration() | 它返回 expires 头部文件中的值。 |
| static FileNameMap getFilenameMap() | 它从数据文件加载文件名映射。 |
| String getHeaderField(int n) | 它返回第 n 个头部字段的值 |
| String getHeaderField(String name) | 它返回指定名称的头部字段的值。 |
| long getHeaderFieldDate(String name, long Default) | 它返回解析为数字的指定字段的值。 |
| int getHeaderFieldInt(String name, int Default) | 它返回解析为数字的指定字段的值。 |
| String getHeaderFieldKey(int n) | 它返回第 n 个头部字段的键。 |
| long getHeaderFieldLong(String name, long Default) | 它返回解析为数字的指定字段的值。 |
| Map<String, List<String>> getHeaderFields() | 它返回头部字段的不可修改的 Map。 |
| long getIfModifiedSince() | 它返回对象的 ifModifiedSince 字段的值。 |
| InputStream getInputStream() | 它返回一个输入流,该输入流从开放连接读取。 |
| long getLastModified() | 它返回 last-modified 头部字段的值。 |
| OutputStream getOutputStream() | 它返回一个输出流,该输出流写入连接。 |
| Permission getPermission() | 它返回一个权限对象,表示建立由该对象表示的连接所需的权限。 |
| int getReadTimeout() | 它返回读取超时设置。 |
| Map<String, List<String>> getRequestProperties() | 它返回连接的指定通用请求属性的值。 |
| URL getURL() | 它返回 URLConnection 的 URL 字段的值。 |
| boolean getUseCaches() | 它返回 URLConnection 的 useCaches 字段的值。 |
| Static String guessContentTypeFromName(String fname) | 它尝试根据 URL 的指定文件组件来确定对象的 MIME 类型。 |
| static String guessContentTypeFromStream(InputStream is) | 它尝试根据输入流开头的字符来确定输入流的类型。 |
| void setAllowUserInteraction(boolean allowuserinteraction) | 它设置此 URLConnection 的 allowUserInteraction 字段的值。 |
| static void setContentHandlerFactory(ContentHandlerFactory fac) | 它设置应用程序的 ContentHandlerFactory。 |
| static void setDefaultAllowUserInteraction(boolean defaultallowuserinteraction) | 它将所有未来 URLConnection 对象的 allowUserInteraction 字段的默认值设置为指定值。 |
| void steDafaultUseCaches(boolean defaultusecaches) | 它将 useCaches 字段的默认值设置为指定值。 |
| void setDoInput(boolean doinput) | 它将此 URLConnection 的 doInput 字段的值设置为指定值。 |
| void setDoOutput(boolean dooutput) | 它将 URLConnection 的 doOutput 字段的值设置为指定值。 |