본문 바로가기

장기 프로젝트

spring java 파일 삭제 코드 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 import java.io.File; public class FileDeletionExample { public static void main(String[] args) { // 삭제할 파일 경로 String filePath = "C:\\example\\file.txt"; // File 객체 생성 File file = new File(filePath); // 파일이 존재하는지 확인 if (file.exists()) { // 파일 삭제 file.delete(); System.out.println("파일이 삭제되었습니다."); } else { System.out.println("파일이 존재하지 않습니다."); } } .. 더보기
java에서 서버이름 가져오기 java 소스 private void processSessionCookie(HttpSession session){ Cokie cookie = new Cookie("SSIONID", session.getid()); String contextpath = getContextPath(); cookie.sePath(contextpath)' response.addCookie(cookie) setAttribue("COOKIE_OVERWRITTEN_FLAG", true); } jsp 화면 더보기
엑셀 다운로드 @RequestMapping("/potal/excelDownload.do") public void excelDownload(modelMap model, HttpServletRequest request, httpServletResponse response, @ModelAttribute("exVo") ExVO vo) throws Exception { List list1 = assService.userlistExcel(vo); List list2 = assService.userlistExcel2(vo); Map(String, Object> beans = new HashMap(); beans.put("list1" list1); beans.put("list2" list2); MakeExcel me = new Ma.. 더보기
[JAVA]숫자외 항목 체크 //숫자외 항목있는지 체크 private boolean checkNumberForm(String s){ if(countChar(s,".") > 1){ return false; } double number = Double.parseDouble(s); Strign checkNumber = Strigfn.format("$.3f", numbr); rerurn checkNumbr.trim().replaceAll("[.0-9]","").equals("") ? true : false; } //소수점 2번 입력 체크 private int countChar(String str, String ch){ return str.length() - str.replace(String.valueOf(ch),"").length(); }.. 더보기
임시번호 생성(JAVA) 방법 String randomPwd = _getRandomPassword(10) private String _getRandomPassword(int len){ char[] charSet = new char[] {''0,'1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'} int idx = 0; StringBuffer sb = new StringBuffer(); for(int i = 0; i < len; i++){ idx = (int) (charSet.length * Math.random()); sb.append(c.. 더보기
[Oracle] 테이블 조인하기(JOIN ~ USING) 3-2 테이블 조인하기(JOIN ~ USING) NATURAL JOIN의 단점은 동일한 이름을 가지는 칼럼은 모두 조인되는데, USING문을 사용하면 컬럼을 선택해서 조인을 할 수가 있다. #형식SELECT table1.컬럼, table2.컬럼 //조회하고 싶은 컬럼명의 리스트를 나열, 출력할 내용FROM table1 JOIN table2 //조회하고 싶은 테이블명을 기술USING(컬럼) //조인할 컬럼 #예제 JOIN ~ USINGSELECT E.EMPLOYEE_ID, D.DEPARTMENT_NAMEFROM EMPLOYEES E JOIN DEPARTMENTS D USING(DEPARTMENT_ID); 더보기
[Oracle]테이블 조인하기(NATURAL JOIN) 3-2 테이블 조인하기(NATURAL JOIN) 조인 칼럼에 테이블 별칭을 사용하면 오류가 발생한다는 점과 조인에 참여하는 두 테이블 모두에서 동일한 이름과 테이블 유형을 가진 컬럼이 존재해야 한다는 점에 주의해야합니다. #형식SELECT table1.컬럼, table2.컬럼 //조회하고 싶은 컬럼명의 리스트를 나열, 출력할 내용FROM table1 NATURAL JOIN table2 //조회하고 싶은 테이블명을 기술WHERE 조건 //조회하고 싶은 로우의 조건을 기술 #예제 NATURAL JOINSELECT E.EMPLOYEE_ID, D.DEPARTMENT_NAME FROM EMPLOYEES E NATURAL JOIN DEPARTMENTS D WHERE DEPARTMENT_ID = 50; 더보기
[Oracle] 테이블 조인하기(EQUI JOIN) 3-1 테이블 조인하기(EQUI JOIN) 둘 이상의 테이블을 연결하여 데이터를 검색하는 방법이다.보통 둘 이상의 행들의 공통된 값 Primary Key 및 Foreign Key 값을 사용하여 조인 한다. #형식SELECT table1.컬럼, table2.컬럼 //조회하고 싶은 컬럼명의 리스트를 나열, 출력할 내용FROM table1, table2 //조회하고 싶은 테이블명을 기술WHERE table1.컬럼 = table2.컬럼 //조회하고 싶은 로우의 조건을 기술 #예제 EQUI JOINSELECT * FROM EMPLOYEES, DEPARTMENTS WHERE EMPLOYEES.DEPARTMENT_ID = DEPARTMENTS.DEPARTMENT_IDAND DEPARTMENTS.DEPARTMENT_I.. 더보기
[JAVA] 알고리즘-수박수박수박 //내가 만든 JAVA 수박수박public class WaterMelon {public String watermelon(int n){String a = "수";String b = "박"; String sum = ""; for(int i=0; i 더보기
[JAVA] 알고리즘-짝수와 홀수 //내가 만듬 java 짝수와 홀수public class EvenOrOdd { String evenOrOdd(int num) { String result = ""; if(num % 2 == 0){ result = "Even"; }else if(num % 2 == 1){ result = "Odd"; } return result; } public static void main(String[] args) { String str = "1 2 3 4"; EvenOrOdd evenOrOdd = new EvenOrOdd(); //아래는 테스트로 출력해 보기 위한 코드입니다. System.out.println("결과 : " + evenOrOdd.evenOrOdd(3)); System.out.println("결과 : ".. 더보기