java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 8080):
connect
failed: ECONNREFUSED (Connection refused)
...
....
....
解决方法:
String url = "http://localhost:8080/notice/test.txt"; 修改成 String url = "http://本机IP:8080/notice/test.txt";
主机ip不能使用localhost或者127.0.0.1,使用真实ip地址即可。