자바 URL 클래스

2019. 12. 6. 20:14Java

728x90

URL = Uniform Resource Locator
인터넷상의 자원에 대해 참조하기 위해 만들어진 것


URL 클래스는 Write-Once Class로 한 번 만들고 나면 속성(포트, 파일이름, 호스트이름)을 변경할 수 없다.

new URL("http://septemberchoe.cafe24.com:80/");
new URL("http", "septemberchoe.cafe24.com", "/index.html");
new URL("http", "septemberchoe.cafe24.com", 80, "/index.html");


URL 객체에는 openStream()이라는 하위 메소드가 있는데,

이를 호출하여 매우 쉽게 사이트의 정보(HTML, JSON, XML, OpenAPI 등의 데이터)를 읽어들일 수 있다.


참고자료:

https://m.blog.naver.com/varient/80052568297

https://needjarvis.tistory.com/258

https://oingbong.tistory.com/60

728x90
반응형