语言翻译API

发布于 2024-08-31 08:48:14 字数 1575 浏览 3 评论 0原文

如何转换 Java 中的语言?是否存在任何 API 可以将任何语言转换为任何其他语言?我正在使用 Google Translate API,但它给了我以下异常。

java.lang.Exception: [google-api-translate-java] Error retrieving translation.
at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:123)
at com.google.api.translate.Translate.execute(Translate.java:69)
at com.nextenders.client.beans.ruleengine.RuleEngineTest.main(RuleEngineTest.java:27)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
null
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:107)
... 2 more 

如果有人知道任何翻译API,请告诉我。

How can i convert language in my Java? Is there any API exist, which convert any language to any other language? I am using Google Translate API, but it giving me below exception.

java.lang.Exception: [google-api-translate-java] Error retrieving translation.
at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:123)
at com.google.api.translate.Translate.execute(Translate.java:69)
at com.nextenders.client.beans.ruleengine.RuleEngineTest.main(RuleEngineTest.java:27)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
null
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:107)
... 2 more 

If anybody knows any API for translation, please tell me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云雾 2024-09-07 08:48:14

正如 JavaRanch 上的人建议的那样, API 连接存在问题

在您指定要连接的 URL 的地方,有东西​​阻止了该连接,请检查是否可以通过 ping 访问该地址

As suggested by the guy on JavaRanch, there is an issue with the connection to the API

Somewhere you will have specified a URL to connect to, something is blocking that, check you can access that address via ping

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文