Network Programming (2) -- connect the parent class URLConnection and urlconnectionIn network programming (1), we learned that if you want to access resources of other hosts, you need to know the URL of the resource. If we know the URL, how can we access resources on the host? This article focuses on the basic parent class URLConnectiion of Android Network Programming in Java, which uses URLs to access host resources, the features of each subclass fur
URLConnection call interface, urlconnection call
Preface:
The project is a java web, jdk1.4, weblogic 7, and other. net system, using the interface developed by wcf. The other party provides the interface url address and description for calling in post mode, and directly returns the json array (data in json array format) without passing parameters)
There are many methods to call interfaces, such as framewo
Use URL and urlconnection (multi-thread download)
17.2.3 use URL and urlconnection The URL (Uniform Resource Locator) object represents a unified resource locator, which is a pointer to the Internet "resource. A resource can be a simple file or directory, or a reference to a more complex object, such as a query of a database or search engine. Generally, a URL consists of a protocol name, host, po
The OpenConnection () method of the URL returns a URLConnection object that represents the communication connection between the application and the URL. A program can send a request to the URL through an URLConnection instance to read the resource referenced by the URLtypically creating a connection to a URL and sending a request, reading the resource referenced by this URL requires the following steps:
Detailed description of urlconnection parameters in JDK
From: http://www.blogjava.net/supercrsky/articles/247449.htmlFor the issue of connecting servlet with urlconnection in JDK, although there are some problems on the internet, it only illustrates one or several problems, which are solved by FAQ and scattered, now I will summarize the usage experience of this class in the project as follows:
1:> URL reque
In Java network programming let us get a network address resources, we often use the URL Uniform Resource Locator (uniform Resource Locator), URL class Java.net.URL. The URL is defined as follows:
[Scheme :] scheme-specific-part[ # Fragment]
where the square brackets [...] are used to describe optional components, characters : and # represent themselves. View the API for more information.
A, URL
The main methods are as follows:
1. Construction method
The URL (string spec) creates a URL object
The openconnection method of the URL returns a urlconnection, which indicates the communication connection between the application and the URL. The program can send a request to the URL through its instance to read the resources referenced by the URL.
The following is a simple example:
Activity:
Package COM. home. urlconnection; import Java. io. ioexception; impo
URLs and URLConnection classesURLs in the network (Uniform Resource Locator) are abbreviations for Uniform Resource locators. It represents the address of a resource on the Internet. Through the URL we can access various network resources on the Internet, such as the most common www,ftp site. URLs can be thought of as "pointers" to Internet resources, which can be used to obtain information about Internet resources, including information about the Inp
For the issue of connecting Servlet with URLConnection in JDK, although there are some problems on the internet, it only illustrates one or several problems, which are solved by FAQ and scattered, now I will summarize the usage experience of this class in the project as follows:
1:> URL request category:
There are two types: GET and POST requests. The difference between the two is:
A: get requests can get static pages, or put parameters after URL stri
For the JDK in the URLConnection connection servlet problem, although the Internet has been involved, but only to explain a certain or a few problems, is the way to solve the FAQ, and relatively fragmented, now on the use of this class I in the project experience to do the following summary:1:> the category of the URL request:Divided into two categories, get and post requests. The difference between the two is:A:) Get request can get a static page, or
For the issue of connecting servlet with urlconnection in JDK, although there are some problems on the internet, it only illustrates one or several problems, which are solved by FAQ and scattered, now I will summarize the usage experience of this class in the project as follows:1:> URL request category:There are two types: Get and post requests. The difference between the two is:A: GET requests can get static pages, or put parameters after URL strings
in front of network programming (1) We learned that if you want to access the resources of other hosts, then you need to know the URL of the resource. So if we know the URL, how do we go toaccess the resources on its host? This articlemainly about the Java language Programming Android network programming of the most basic parent class urlconnectiion, the class is the use of URLs to achieve host resource access, each subclass of its characteristics are further optimized and support the new networ
Normal download and URLConnection 6 (64), urlconnection64
Normal download
When the service uses breakpoint download, the response information is 206.
UrlConnection-HttpurlConnection. -Obtain the urlconnection instance through URL.
Normal download example
Package cn. demo; import java. io. fileOutputStream; import java.
Public abstract class urlconnection{public URL GetURL () //Return the currently connected URL object public int Getcontentlength () //Returns the length of the resource file public String getContentType ()//returns the type of the resource file public long getlastmodified () // Returns the last modified date of the resource file}The OpenConnection () method of the URL class can create a URLConnect
Write in front:There are many ways to call WebService: 1. Generate the client code directly from the client using the tool, copy the code into the project and invoke it, 2. Use the corresponding WebService framework to invoke, for example, if our server development uses axis, then I can import the corresponding axis jar on the client side. Package, and then use its related methods to make the call; 3.js call; 4.UR
Reprint Please specify Source: http://blog.csdn.net/bettarwang/article/details/41229955The URL (Uniform Resource Locator) object represents a Uniform resource locator, which is a pointer to an Internet resource. The URL consists of the protocol name, host, port, and resource path component, which satisfies the following format:Protocol://host:port/pathFor example, http://kan.sogou.com/dianying/is a URL address.The URL provides several construction met
Network Programming series in Android (1): URLConnection
The URL (Uniform Resource Locator) object represents a unified Resource Locator, which is a pointer to Internet resources. The URL consists of the protocol name, host, port, and resource Path Components:
protocol://host:port/path
For example, http://kan.sogou.com/dianying/#a urladdress.URL provides multiple constructor methods for creating URL obj
This article shows how to get the HTTP response header information through URLConnection
1. Get header information from the response
URL obj = new URL ("http://www.bianceng.cn");
URLConnection conn = Obj.openconnection ();
map
2. Get the server information from the response header
map
Complete example
Package com.qiyadeng.http;
Import Java.net.URL;
Impor
Do not say anything more, take URLConnection class for example, do a get the source code of the website
public class Urldemo {public static void Main (string[] args) {Scanner scan = new Scanner (system.in);System.out.println ("Please enter the URL:");String urlstr = "http://" +scan.next ();try {URL url = new URL (urlstr); Instantiate the URLSTR string URL as a URL to locate the address s
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.