Discover java code to convert html to pdf, include the articles, news, trends, analysis and practical advice about java code to convert html to pdf on alibabacloud.com
Demand:Handle a piece of HTML code For example:11111Mind Mapping:Code:public static string CHECKPP (string content) {string str;int time =0;int pos =0;int path =0;boolean flag =true;int index1 = 0;int Index2 =0;//Ensure that the positions are Log of the execution example:11111Analysis:1. Since only the 2. Convert string to StringBuffer for easy insert operation.3
This article mainly introduces the method code of replacing HTML tags in Java, the need for friends can refer to the followingReplaceAll ("\\[a-za-z]{0,9};", "" "). ReplaceAll (" The source code is as follows:/*** String Substitution*/ PackageCom.you.model; /*** HTML Tag rep
Sometimes we get to the page need to parse in the Java code, get the data in the HTML, Jsoup is a very convenient tool.
One, what is jsoup.
Official website: http://jsoup.org/
can download the corresponding jar on the website
Popular will be Jsoup is a page of things to parse
Second, the example
1. The page, through the query to get some data:
2. Source
Java generated two-dimensional code
Related to some of the main class library, convenient for everyone to download:
Code Lib:Qrcode_swetake.jar (Website introduction--http://www.swetake.com/qr/index-e.html)
Decoding Lib:qrcode.jar (Website introduction--http://sourceforge.jp/projects/qrcode/)
"One", Code:
Qrcodeenc
I am developing a map program. I am more willing to use this method than using XML to write Android interfaces,Instead of using the MapView provided by Android, you can use the Google Maps JavaScript API that you have been familiar with before,Load HTML code in Android WebView, and use the powerful interaction between Java and Js provided by Android,Use web pages
The principle is similar to the servlet that generates JSP in Java. We can use PrintStream to output data to HTML files.
First, create a StringBuilder object and add an HTML statement to it by Append method. As shown in the following example:
Copy Code code as follows
1. Replace HTML tags
Copy Code code as follows:
ReplaceAll ("\\[a-za-z]{0,9};", "" "). ReplaceAll ("
The source code is as follows:
Copy Code code as follows:
/**
* String substitution
These two days need to do something, need to crawl other people's web page some information. Finally, use Htmlparser to parse HTML.
Read it directly from the code:
First you need to note that the import package is: The package under import Org.htmlparser
Copy Code code as follows:
listtry{
Parser Parser
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.