導航:首頁 > 編程語言 > java翻譯api

java翻譯api

發布時間:2025-01-28 08:11:25

Ⅰ 怎麼將百度翻譯api調用進資料庫

最近項目要用到一點翻譯的功能,使用網路翻譯api

有使用上的限制,對我來說已經夠用了介面限制
網路翻譯API的使用頻率默認限制為每個IP 1000次/小時。
如果該頻率不能滿足您的使用需求,請聯系:[email protected]
項目中使用gson來解析返回的json數據

import java.util.List;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.GetMethod;

import com.google.gson.Gson;

/**
* @author Ericlin
*
* 2013-9-25
*/
public class Bai {

private static String url ="http://openapi..com/public/2.0/bmt/translate";

private static String api_key ="****************";

public static void main(String[] args) throws Exception {
HttpClient client = new HttpClient();
GetMethod method = new GetMethod(url);
method.setQueryString(new NameValuePair[] {
new NameValuePair("from","zh"),
new NameValuePair("to","en"),
new NameValuePair("client_id", api_key),
// 多條內容用
分隔
new NameValuePair("q","【微語】任何一件無縫的天衣,都需要你一針一線認真縫合。
海天盛宴大野模,土包子眼中的白富美。") });

client.executeMethod(method);
String response = new String(method.getResponseBodyAsString());
System.out.println(response);
method.releaseConnection();

Gson gson = new Gson();
BaiTrans bt = gson.fromJson(response, BaiTrans.class);
for (TransResult tr : bt.getTrans_result()) {
System.out.println(tr.getDst());
}
}

class BaiTrans {
private String from;
private String to;
private List<TransResult> trans_result;

public String getFrom() {
return from;
}

public void setFrom(String from) {
this.from = from;
}

public String getTo() {
return to;
}

public void setTo(String to) {
this.to = to;
}

public List<TransResult> getTrans_result() {
return trans_result;
}

public void setTrans_result(List<TransResult> trans_result) {
this.trans_result = trans_result;
}
}

class TransResult {
public String getSrc() {
return src;
}

public void setSrc(String src) {
this.src = src;
}

public String getDst() {
return dst;
}

public void setDst(String dst) {
this.dst = dst;
}

private String src;
private String dst;
}
}

Ⅱ javaAPI文檔里的這句話怎麼翻譯

String greet="hello";
int cp=greet.offsetByCodePoints(1,4);
System.out.println(cp);
輸出結果是5,

public int offsetByCodePoints(int index,
int codePointOffset)
返回此 String 中從給定的 index 處偏移 codePointOffset 個代碼點的索引。
文本范圍內由 index 和 codePointOffset 給定的未配對代理項各計為一個代碼點

個人理解,就是從這個字元串,index為1的點開始,正向偏移4之後的索引號
所以就是5了……

Ⅲ 求java API 1.8的中文幫助文檔

記得我回答過類似的問題,第一個鏈接裡面有Java 1.8的,但是是英文版的,1.6有中文版的

http://javadoc.allimant.org/

JDK1.6API中文版(全)
————————-
* HTML 格式(在線英文) http://java.sun.com/javase/6/docs/
* HTML 格式(在線中文) http://download.java.net/jdk/jdk-api-localizations/jdk-api-zh-cn/publish/1.6.0/html/zh_CN/api/index.html
* zip 格式(中文) http://download.java.net/jdk/jdk-api-localizations/jdk-api-zh-cn/publish/1.6.0/html_zh_CN.zip
* CHM 格式(中文) http://download.java.net/jdk/jdk-api-localizations/jdk-api-zh-cn/publish/1.6.0/chm/JDK_API_1_6_zh_CN.CHM
JDK1.5API中文版(全)
————————-
* HTML 格式(在線英文) http://java.sun.com/javase/5/docs/
* HTML 格式(在線中文) http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/index.html
* zip 格式(中文) http://gceclub.sun.com.cn/Java_Docs/html_zh_CN.zip
* CHM 格式(中文) http://download.java.net/jdk/jdk-api-localizations/jdk-api-zh-cn/builds/JDK_API_1_5_zh_CN.CHM
目前在 http://developers.sun.com.cn 已正式宣布發布Java SE 6 API 中文版。
大家也可以從以下網址下載:
* HTML 格式 ( http://download.java.net/jdk/jdk-api-localizations/jdk-api-zh-cn/publish/1.6.0/html/zh_CN/api/index.html )
* zip 格式 ( http://download.java.net/jdk/jdk-api-localizations/jdk-api-zh-cn/publish/1.6.0/html_zh_CN.zip )
* CHM 格式 ( http://download.java.net/jdk/jdk-api-localizations/jdk-api-zh-cn/publish/1.6.0/chm/JDK_API_1_6_zh_CN.CHM )

閱讀全文

與java翻譯api相關的資料

熱點內容
php正整數驗證 瀏覽:363
有個腹黑程序員男友是什麼體驗 瀏覽:110
pdf添加文本框 瀏覽:770
系統文件夾很大沒有文件 瀏覽:74
蘇寧電器app如何還分期 瀏覽:635
蘋果怎麼在主屏幕創建文件夾 瀏覽:627
河南雲伺服器租用虛擬主機 瀏覽:361
centos修改ip命令 瀏覽:779
租用伺服器屬於什麼服務類型 瀏覽:135
英雄聯盟說沒有網路連接到伺服器地址 瀏覽:28
單片機周期信號波形識別 瀏覽:42
演算法驅動的成長史 瀏覽:936
好又省APP怎麼用 瀏覽:576
pdf在線格式轉換jpg格式轉換器 瀏覽:868
中興捧月演算法大賽第二場 瀏覽:15
穿雲伺服器 瀏覽:394
單片機核心電壓表 瀏覽:151
最強大逃頂通達信指標源碼 瀏覽:441
java程序員面試寶典歐立奇 瀏覽:457
cad命令不要跟著游標 瀏覽:200