The method of extracting URL link by Android programming _android

Source: Internet
Author: User

The example in this article describes the method of Android programming to extract URL links. Share to everyone for your reference, specific as follows:

 import Java.io.BufferedReader; 
Import java.io.IOException; 
Import Java.io.InputStream; 
Import Java.io.InputStreamReader; 
Import Java.net.URL; 
Import Java.util.regex.Matcher; 
Import Java.util.regex.Pattern; public class URLReader1 {public static void main (String args[]) throws ioexception{URL name = new URL ("Http://www.bai 
 Du.com "); 
 InputStream input = Name.openstream (); 
 InputStreamReader ISR = new InputStreamReader (input); 
 BufferedReader buffer = new BufferedReader (ISR); 
 String Inputline; 
 Dosometest (); 
 while ((Inputline = Buffer.readline ())!= null) {Docheckurl (inputline); 
 Break 
 } buffer.close (); 
 static void Docheckurl (String str) {pattern pattern=pattern.compile ("<a\\s+href[^>]*>"); 
 Matcher Matcher=pattern.matcher (str); 
 while (Matcher.find ()) {System.out.println ("+" +str.substring (Matcher.start (), Matcher.end ())); } 
 } 
}

For more information on Android-related content readers can view the site: "Android View tips Summary", "Android Layout Layout Skills Summary", "Android Development introduction and Advanced Course", " Android Debugging tips and FAQ Solutions Summary, Android Multimedia tips summary (audio, video, audio, etc.), "Android Basic Components Usage Summary" and "Android Control usage Summary"

I hope this article will help you with the Android program.

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.