首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

应用代理访问Google翻译接口

2012-10-26 
使用代理访问Google翻译接口lib包见附件public class Test {public static void main(String[] args) {//

使用代理访问Google翻译接口
lib包见附件

public class Test {public static void main(String[] args) {// Set the HTTP referrer to your website address.    try {    System.setProperty("http.proxyHost", "ip地址");    System.setProperty("http.proxyPort", "端口号");    Translate.setHttpReferrer("http://code.google.com/p/google-api-translate-java/");String translatedText = Translate.execute("hello world", Language.ENGLISH, Language.CHINESE_SIMPLIFIED);System.out.println(translatedText);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}}


执行结果:

你好世界

热点排行