[java/crawling] 크롤링 웹페이지 그대로 복사해오기 public static void main(String[] args) throws Exception{ String page= "가져올 웹주소"; URL url = new URL(page); /* !Stream단어가 들어가면 read만 사용 무조건 int!(Byte 이용), Reader readLine (String)! */ /* !flush(): BufferedOUtputStream때 사용 ! */ InputStream is = url.openStream(); //net에서만 사용 BufferedInputStream bs = new BufferedInputStream(is); //배열 byte[] byte html[]=new byte[is.available()]; //1024써도됨 //FileOutput.. 2022. 7. 3. [java/net] 인터넷 URL 이미지 주소를 이용하여 이미지를 내 pc에 copy하기 public static void main(String[] args) throws Exception{ Scanner sc = new Scanner(System.in); System.out.println("웹에서 가져올 이미지 주소를 입력하세요"); String url =sc.next(); URL u = new URL(url); //USL 메소드/사용자 입력값 선언 URLConnection con = u.openConnection(); //URL 메소드 생성 int imgsize = con.getContentLength(); // 이미지 크기 확인 System.out.println(imgsize); //이미지 크기 출력 String imgtype=con.getContentType(); //이미지 TYPE .. 2022. 6. 27. [java/net] 인터넷 URL 이미지 주소로 파일 크기/형태 확인 URLConnection/openConnection 인터넷 URL 이미지 주소로 파일 크기/형태 확인 및 내 PC에 저장하는 법 public class net2 { public static void main(String[] args) throws Exception{ Scanner sc = new Scanner(System.in); System.out.println("웹에서 가져올 이미지 주소를 입력하세요"); String url =sc.next(); URL u = new URL(url); //USL 메소드/사용자 입력값 선언 URLConnection con = u.openConnection(); //URL 메소드 생성 int imgsize = con.getContentLength(); // 이미지 크기 확인 System.out.println(imgsize.. 2022. 6. 27. [java/net] InetAddress ,getByName,getAllByName,getHostAddress 사용 예시 InetAddress : IPnetworkAddress getByName : 접속할 도메인명 getAllByName :도메인 IP정보 확인 (!배열!) getHostAddress:IP주소(숫자)를 문자열로 반환 public static void main(String[] args) throws Exception { //server에 연결 하기위해 //InetAddress : IPnetworkAddress //getByName : 접속할 도메인 주소명을 말합니다. InetAddress ia = InetAddress.getByName("localhost"); //!!자기 기본 정보 확인!! System.out.println(ia); //System.out.println(ia.getHostName()); // .. 2022. 6. 27. 이전 1 다음