使用java转换货币

使用java转换货币,java,gson,Java,Gson,我需要在固定货币之间转换。 我找到了一个简单的教程: 这是我的代码:(顺便说一下,我正在导入gson库) } 我得到了一个错误: Exception in thread "main" java.io.FileNotFoundException: http://www.google.com/ig/calculator?hl=en&q=GBP%3D%3FAUD at sun.net.www.protocol.http.HttpURLConnection.getInputSt

我需要在固定货币之间转换。 我找到了一个简单的教程:

这是我的代码:(顺便说一下,我正在导入gson库)

}

我得到了一个错误:

 Exception in thread "main" java.io.FileNotFoundException: http://www.google.com/ig/calculator?hl=en&q=GBP%3D%3FAUD
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at SeedGenerator.main(SeedGenerator.java:45)
有人能解释一下我做错了什么吗。我认为这可能是一个实际的网址问题。我是不是用错了


提前感谢

这是正确的
字符串
结构,使用:


您是否尝试浏览到URL?你做过任何调试吗?就像错误所说的,这个页面不存在。
 Exception in thread "main" java.io.FileNotFoundException: http://www.google.com/ig/calculator?hl=en&q=GBP%3D%3FAUD
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at SeedGenerator.main(SeedGenerator.java:45)
"https://www.google.com/finance/converter?a=" 
+ toConvert + "&from=" 
+ firstCurrency + "&to" 
+ secondCurrency;