在线调用google翻译
????? 转:http://mylfd.iteye.com/blog/1965585?
?
????? 很是无奈,google翻译收费了,像我们一般人就用不起了.只能另想办法了.上一篇介绍了使用bing也是解决的办法之一,但是不可否认还是google翻译的更加理想.
?????? 首先下载项目所需要的jar包:jsoup-*.jar,commons-io-*.jar,commons-logging-*.jar.为了提高可扩展性我使用了接口,看代码:
- public?static?void?main(String[]?args)?{??????????TranslateUtil?translate?=?new?TranslateToGoogle()?;??????????try?{??????????????System.out.println(translate.translate("世界你好!",?"en"))?;??????????}?catch?(Exception?e)?{??????????????e.printStackTrace();??????????}??????}??
?这里需要注意,如果使用get请求是有字数限制的.