Android applicationsProgramYou can use the getinputstream () method of httpurlconnection to access files on the web server. However, during debugging, I always prompt a connection refused exception. Then I analyzed it carefully:
The URL of the server file to be downloaded is http: // localhost: 8080/mp3player/resources. XML. Because my mobile phone is connected to my computer via USB, I initially thought that my mobile phone could access my computer's web programs, but this is obviously incorrect. Because the mobile phone is connected to the router through WiFi (the router does not distinguish whether the current connected device is a mobile phone or a computer), http: // localhost: 8080/mp3player/resources is used. xml url, the program will search for the web program on the mobile phone, apparently there is no web program on the mobile phone. Therefore, the correct method is to use the IP address of the computer as the URL, so the correct URL should be: http: // 192.168.1.100: 8080/mp3player/resources. XML, which is passed the test. Remember.