使用代理访问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();}}}
执行结果:
你好世界