안드로이드 개발 질문/답변
(글 수 45,052)
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
URL sourceUrl = new URL("http://localhost:8080/example.xml");
xr.parse(new InputSource(sourceUrl.openStream()));
로컬호스트에 xml을 넣고 XMLReader로 읽어오려는데 오류가 발생하네요.
에러내용은 >>>> java.net.ConnectException: localhost/127.0.0.1:8080 - Connection refused
톰켓에 설정을 해줘야하는건가요??




자답 입니다. 개발문서에 있네요;
Referring to localhost from the emulated environment
If you need to refer to your host computer's localhost, such as when you want the emulator client to contact a server running on the same host, use the alias 10.0.2.2 to refer to the host computer's loopback interface. From the emulator's perspective, localhost (127.0.0.1) refers to its own loopback interface.