[java/응용문제] 사용자 입력숫자 메소드 result활용하여 총합 구하기 메인에서 Scanner 돌린 ver. /*[문제1] 총 8번의 사용자가 숫자를 입력 합니다. 해당 숫자를 입력하는 Scanner은 userinput이라는 메소드 에서 처리를 해야 하며 해당 모든 값에 대한 더한 결과는 result에서 값이 출력 되도록 하는 프로그램을 제작하시오. 힌트 (외부클래스에서 메소드2개 생성) */ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int user2[]=new int[8]; for(int i=0;i 2022. 6. 30. [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. [java/이미지 파일 용량제한] InputStream, byte, available() public static void main(String[] args) throws IOException{ String file="C:\\java5\\File_Strame\\src\\img2.jpg"; InputStream is = new FileInputStream(file); byte filesize[] = new byte[is.available()]; // 1. 전체 읽고 용량확인 int total = is.read(filesize); //2. 용량 값 선언 if(total > 92160) { //용량 제한 System.out.println("이미지 제한 용량은 90kb까지 입니다."); } else { System.out.println("정상적으로 등록되었습니다."); } } 결과값 2022. 6. 27. 이전 1 ··· 16 17 18 19 20 21 다음