전체 글
-
람다식으로 특정 확장자 파일명 불러오기 (+ forEach()와 향상된 for문)JAVA/스트림, 컬렉션 프레임워크, 람다 2024. 6. 7. 12:23
▤ 목차" data-ke-type="html">HTML 삽입미리보기할 수 없는 소스 ✔ fileFilter ( 특정 확장자 파일 가져오기 )⌨ 형식public class MyLambda3 { public MyLambda3() { // 람다 표현식 사용 test(); //thread 사용 } private void test() { //특정 디렉토리(폴더)에 있는 파일 목록 걸러보기 File direc = new File("c:/work"); //fileFilter 함수형 인터페이스로 람다식 처리, 확장자 txt만 필터링 File[] files = direc.listFiles((File file) ->file.isFile() && file.getName().endsWith(".txt..
-
람다 표현식(lambda Expression)JAVA/스트림, 컬렉션 프레임워크, 람다 2024. 6. 6. 17:22
▤ 목차">HTML 삽입미리보기할 수 없는 소스 ✔ 람다 표현식java SE 8부터 나온 람다 표현식은 메서드를 하나의 식으로 표현한 것을 말한다.하나의 추상 메서드를 가지고 있는 인터페이스를 가지고 있어야 사용이 가능하다.무명 클래스를 화살표 기호를 사용하여 짧게 줄일 수 있다.(parameter ,,,) -> { body }만약, 람다식이 하나의 메서드를 호출하는 경우 ::으로 표현할 수 있다.1) 클래스 이름 :: 메서드 이름2) 참조변수 :: 메서드 이름가독성이 좋은 쪽으로 선택하자.💻 코드로 보기interface HelloInter { int calcData(int a, int b);}public class MyLambda1 implements HelloInter { @Override ..
-
메소드 재정의(Override)와 부모 메소드 호출(super)JAVA/클래스,상속,인터페이스,기본API 2024. 6. 5. 10:47
▤ 목차" data-ke-type="html">HTML 삽입미리보기할 수 없는 소스 상속을 받아 사용하면서 자식 클래스에서 사용하기 적합하지 않을 수 있다.상속된 일부 메서드는 자식 클래스에서 다시 수정해서 사용해야 한다.이런 경우, 재정의 할 수 있는데 이를 메서드 오버라이드라고 한다.✔ 오버라이드?상속된 메서드의 내용이 자식 클래스에 맞지 않을 경우, 자식 클래스에서 동일한 메서드를 재정의 하는 것을 말한다.편하게 말하자면 부모의 정의가 마음에 들지 않으면 자식 클래스에서 다시 정의하는 것이다.대신, 오버라이드를 하기 위해서는 규칙이 있다.아래 규칙으로 인해 오버라이딩이 되었다면 부모 객체의 메서드는 숨겨지기 때문에메서드를 호출하면 오버라이딩 된 자식의 메서드가 호출된다.⌨ 규칙접근 제한을 더 강하게..
-
Properties 파일이란?JAVA/JDBC 2024. 6. 4. 13:30
▤ 목차" data-ke-type="html">HTML 삽입미리보기할 수 없는 소스 먼저 properties 파일을 만들어서 어떤 방식으로 돌아가고 java 프로그램에 호출할 수 있는지 확인해보자.파일을 직접 만들고 코드로 돌려보자.이후 properties 파일의 개념에 대해 알아보자.✔ Properties 파일 만들기⌨ propertiesfile을 생성한다.이때 확장자는 .properties를 넣어야한다. 해당 파일은 영어는 잘 들어가지만 한글과 같은 글자들은 unicode로 변환된다. 💻 코드로 보기package pack;import java.io.FileInputStream;import java.util.Properties;public class PropertiesTest { public sta..
-
maven, gradle) 파일 만들기, 저장소에서 dependencies 코드 가져오기JAVA/JDBC 2024. 6. 3. 11:36
▤ 목차" data-ke-type="html">HTML 삽입미리보기할 수 없는 소스✔이클립스에서 메이븐 프로젝트 생성🔧 Maven Project 만들기💻 확인✔ 메이븐 저장소에서 jdbc 다운⌨ 메이븐 저장소pom.xml파일이 있다. 해당 파일을 열어보면 버전과 같은 것들이 적혀져있는데,여기에 dependencies를 추가해줄 것이다. https://mvnrepository.com/ 💻 xml 파일 project 부분 오류 시이렇게 pom.xml을 열었을 경우, 오류가 발생할때가 있다.버전 오류이기에 검색을해야한다. 간단한 해결방법은 URL에서 보안을 의미하는 S를 지우는 것이다.보안 설정이 안되어 있는 프로토콜을 사용하면 된다. 👏 결과예전에는 .jar 파일을 직접 build path를 했었다..
-
Tomcat 오류 ) 톰캣을 설치하고 나서 발생한 오류JAVA/기타 2024. 6. 1. 13:57
▤ 목차" data-ke-type="html">HTML 삽입미리보기할 수 없는 소스 ✔ The server cannot be started because one or more of the ports are invalid 🚫 오류 메시지The server cannot be started because one or more of the ports are invalid. Open the server editor and correct the invalid ports 💻 해결 Tomcat의 port 번호가 잘못 설정되었는지 확인해봤지만http/1.1은 8080으로 잘 돌아갔다. 검색 결과 Tomcat admin port 번호가 -로 설정되어있었는데 8005으로 설정해주고 Server Options를 ..
-
JDBC의 개념과 연결 방법, DB CursorJAVA/JDBC 2024. 5. 31. 12:34
▤ 목차" data-ke-type="html">HTML 삽입미리보기할 수 없는 소스✔ JDBC데이터를 가져오는데 가장 먼저 되어야하는 것은 연결이다. 각각 회사에서 만들어 놓은 클래스이다. (드라이버 각 벤더사 홈에서 다운받아야한다.)자바 패키지의 일부로 자바 프로그램과 데이터베이스와 연결하여 데이터를 주고 받게 해주는 프로그래밍 인터페이스(설명서)이다.SQL 처리 관련, DB연결 관련, 데이터베이스 정보와 관련된 사항을 가진다. ⌨ 데이터 처리 관련 인터페이스Class.forName : 드라이버 찾아서 로딩DriverManager : Connection 을 활성화한다.Connection : 데이터베이스와 연결, DriverManager.getConnection()으로 얻는다.statement : SQL..
-
java) Swing 키보드 이벤트 + Frame창 이미지 이동시키기(+Toolkit)JAVA/멀티스레드, 이벤트 2024. 5. 30. 10:32
▤ 목차" data-ke-type="html">HTML 삽입미리보기할 수 없는 소스✔ 이미지 이동시키⌨ 같은 패키지에 복사 💻 이미지 경로 가져오는 방법 해당 이미지가 존재하는 경로이다. 절대 경로만 가능하다. 복사하면 된다. ✔ 키보드로 이미지 이동시키기💻 코드로 보기public class PackMan extends JFrame implements KeyListener { Image image; int x = 100, y = 100; int selImage = 1; public PackMan() { super("상하좌우 화살표를 사용하세요"); setIconImage(Toolkit.getDefaultToolkit().getImage("C:\\work\\src\\pack7GUI\\pack1...