블로그
- JAVA에서 System.in.read()로 문자열 입력 " + k ); ==== 함수화 public static String input(){ System.out.print("Enter : "); String k = ""; int a; try { while(true){ a = System.in.read(); if(a == 10){ break; } k += (char)a; } } catch (IOException e) {
- [영진전문대 컴퓨터정보계열] 자바서버프로그래밍 mysql://localhost/book_db"; String id = "root"; String password = "root1234"; Connection con = null; try 성공"); con = DriverManager.getConnection(url, id, password); System.out.println("데이터베이스 연결 성공"); } catch
- [영진전문대 컴퓨터정보계열 컴퓨터프로그래밍전공] 자바서버프로그래밍 public class qqqq extends JFrame { BufferedImage img; public qqqq() { setTitle("Image Load Test"); try { img = ImageIO.read(new File("aa.jpg")); } catch (IOException e) { System.out.println(e.getMessage(
- Vo객체에서 변수와 값을 가져오는 예제 new DTO(); dto.setSeq(1); dto.setTitle("제목"); dto.setCreatedate(new Date()); dto.setContent("내용내용"); try field.setAccessible(true); Object value=field.get(obj); System.out.println(field.getName()+","+value); } }catch
- [영진전문대 컴퓨터정보계열 컴퓨터프로그래밍전공] 자바서버프로그래밍 ://106.249.39.66/book_db"; String id = "root"; String password = "root1234"; Connection con = null; try 성공"); con = DriverManager.getConnection(url, id, password); System.out.println("데이터베이스 연결 성공"); } catch
- 예외 처리 try / catch / finally try 예외가 발생할 가능성이 있는 범위를 지정 최소 하나의 catch 블록 있어야 함 catch 매개변수는 예외 객체가 발생했을 때 참조하는 내용은 예외 발생 유무나 예외 catch 유무와 상관없이 무조건 수행됨 데이터베이스나 파일을 사용한 후 닫는 기능과 같이 항상 수행해야 할 필요가 있.......
- 45번째 퍼즐 - 피곤한 일 Scriptercs try-catch 구문을 보면 무엇을 출력할지 쉽게 예측할 수 있다 workHard() 메소드는 스스로 StackOverflowError2 를 발생시키기 전까지 재귀 호출을 계속 한다 그러나 try-catch 구문이 있음으로 StackOverflowError 가 발생하면 finally 블록으로 들어가서 workHard().......
- 37번째 퍼즐 - 이상한 예외 되지는 않는다 import java.io.IOException; public class Arcane1 { public static void main(String[] args) { try ; } }} public class Arcane2 { public static void main(String[] args) { try { // 아무 것도 안 넣어도 된다 } catch
- jar 안에 있는 파일을 찾지 못한다? 문제) public static String getProperties(String key) { final Properties properties = new Properties(); try (); } catch (IOException e) { e.printStackTrace(); } return properties.getProperty(key); } 프로젝트 resources
- 38번째 퍼즐 - 초대받지 않은 손님 수 있다 문제는 이 메소드가 정적 필드를 초기화할 때 사용된다는 것으로, 자바는 정적 필드를 초기화할 때 예외가 발생하는 것을 허용하지 않는다 따라서 필드 초기화 부분은 별도로 try-catch The_Unwelcome_Guest { public static final long GUEST_USER_ID = -1; private static final long USER_ID; static { try