效果展示
我爱你中国 我字共7画;我字的笔顺:撇,横,竖钩,提,斜钩,撇,点 爱字共10画;爱字的笔顺:撇,点,点,撇,点,横撇/横钩,横,撇,横撇/横钩,捺 你字共7画;你字的笔顺:撇,竖,撇,横撇/横钩,竖钩,撇,点 中字共4画;中字的笔顺:竖,横折,横,竖 国字共8画;国字的笔顺:竖,横折,横,横,竖,横,点,横
具体代码如下:
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpConnectionManager;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.methods.GetMethod;
/
* 获取中文笔画顺序及笔数
* @author 杨红杰
* @date 2019/10/24 14:46
*/
public class BiHua {
public static void main(String[] args) throws Exception {
String str = "我爱你中国";
System.out.println(str);
for (int i= 0; i < str.length(); i++) {
System.out.println(getBiShunAndBiShu(str.substring(i, i+ 1)));
}
}
public static String getBiShunAndBiShu(String str) throws Exception {
HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
connectionManager.getParams().setDefaultMaxConnectionsPerHost(10);
connectionManager.getParams().setConnectionTimeout(300000000);
connectionManager.getParams().setSoTimeout(300000000);
HttpClient client = new HttpClient(connectionManager);
GetMethod method = new GetMethod("http://bishun.shufaji.com/" + cnToUnicode(str) + ".html");
client.executeMethod(method);
String returnJson = new String(method.getResponseBody(), "utf-8");
int idx1 = returnJson.indexOf("<div id=\"hzcanvas\">");
if (idx1 != -1) {
idx1 += 19;
int idx2 = returnJson.indexOf("</div>", idx1);
returnJson = returnJson.substring(idx1, idx2 == -1 ? returnJson.length() : idx2);
}
return returnJson;
}
/
* 中文转Unicode
* @param cn
* @return
*/
private static String cnToUnicode(String cn) {
char[] chars = cn.toCharArray();
String returnStr = "";
for (int i = 0; i < chars.length; i++) {
returnStr += "0x" + Integer.toString(chars[i], 16);
}
return returnStr;
}
}
今天的文章 java获取中文笔画顺序及笔数分享到此就结束了,感谢您的阅读。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/bian-cheng-ji-chu/85991.html