我正在尝试使链接的示例代码正常工作,但我正在体验一个SocketException (如下所示)。我正在使用java 7。
https://github.com/smartystreets/LiveAddressSamples/blob/master/java/LiveAddressExample.java
IO Exception Error: java.net.SocketException: Connection reset
Exception in thread "main" java.lang.NullPointerException
at com.icat.coastal.processor.SmartyStreetAddress.main(SmartyStreetAddress.java:71)我想这是因为这句话:
DataOutputStream outgoing = new DataOutputStream(urlConn.getOutputStream());我尝试按照这里的建议调整防火墙,但是它没有工作:http://www.javaprogrammingforums.com/java-networking/17319-java-net-socketexception-connection-reset.html
我如何更深入地研究以确定问题,或者你认为什么可能是错误的?
发布于 2015-02-09 18:58:39
我刚刚尝试了一次新的尝试,直接从github示例复制并插入我的auth-id和auth-token。下面是我的终端会话的样子:
$ java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
$ ll
drwxr-xr-x 6 mike staff 204B Feb 9 11:49 ./
drwxr-xr-x 18 mike staff 612B Dec 22 23:01 ../
-rw-r--r-- 1 mike staff 3.2K Feb 9 11:49 LiveAddressExample.java
-rw-r--r-- 1 mike staff 349B Dec 22 23:01 README.md
-rw-r-----@ 1 mike staff 23K Feb 9 11:45 json-simple-1.1.1.jar
$ javac -cp json-simple-1.1.1.jar LiveAddressExample.java
Note: LiveAddressExample.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: LiveAddressExample.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
$ java -cp .:json-simple-1.1.1.jar LiveAddressExample
3785 Las Vegas Blvd S
Las Vegas NV 89109-4333
1600 Amphitheatre Pkwy
Mountain View CA 94043-1351因此,在这一点上,我在复制错误时遇到了困难。我的一位同事在java1.6中尝试了同样的方法,这也起了作用。您是否可以提供关于您的环境的其他详细信息,或者与您对代码所做的编辑有关的任何细节?
https://stackoverflow.com/questions/25389474
复制相似问题