본문 바로가기

개발하자/JAVA고급

(17)
poi 엑셀 다운로드 기능 @RequestMapping(value = "/selectMyUnionMbListExcel.do", method = RequestMethod.POST) public void selectMyUnionMbListExcel(HttpServletRequest request, HttpServletResponse response) throws SQLException, IOException { EduUnionMbVo vo = new EduUnionMbVo(); String deptCode = request.getParameter("deptCode") != null ? request.getParameter("deptCode") : ""; vo.setDeptCode(deptCode); List unionMblist = ..
Thread.yield(); class AThread extends Thread{ public void run(){ int i; for (i = 0; i
쓰레드 안전하게 종료시키는 방법 class Echo extends Thread { private int waitTime; // in millisecs public Echo(String word, int waitTime) { super(word); this.waitTime = waitTime; } public void run( ) { for(int i=0; i
생산자 소비자 패턴(서로가 서로를 깨우는) class Echo extends Thread{ private Thread t; Echo(String word){ super(word); } public void setNextThread(Thread t){ this.t=t; } public void run(){ for(int i=0; i
Thread,InterruptedException,join(); class A{ public static void main(String args[]) throws InterruptedException{ B t1=new B(1,50); B t2=new B(51,100); t1.start(); t2.start(); t1.join(); t2.join(); -->join을 해주지 않으면 계산되기전에 끝나버리는 경우가 발생하여 제대로 된 값이 출력되지 않는다. System.out.println(t1.sum+t2.sum);//5050 } } class B extends Thread{ int num1; int num2; int sum=0; int i; B(int n1,int n2){ num1=n1; num2=n2; } public void run(){ for(i=num1;i
파일보내기/파일크기보내기 package min2; import java.io.*; // 받는부분 import java.net.*; import java.util.*; public class FileR { public static void main(String[] args)throws Exception { Socket s=new Socket("192.168.1.159",7777); // 민정이한테 소켓연결 InputStream is = s.getInputStream(); Scanner sc = new Scanner(is); String str = sc.nextLine(); System.out.println("온거"+str); //String[] k = str.split("/"); //System.out.println("받을데이터크..
웹사이트소스불러오기 import java.io.BufferedInputStream; import java.net.HttpURLConnection; import java.net.URL; class GetTitle { public static final int buffer_size = 1024; public static void main(String[] args) { try{ URL url = new URL("http://docs.oracle.com/javase/8/docs/api/index.html"); HttpURLConnection comm = (HttpURLConnection) url.openConnection(); comm.connect(); byte[] user_buffer = new byte[buffer_size]..
java.util.regex.PatternSyntaxException replaceAll()에.... 1.[]씌워야 할 것들 * ⇒ [*] + ⇒ [+] $ ⇒ [$] | ⇒ [|] 2. \\를 붙여줘야 하는 것들. ( ⇒ \\( ) ⇒ \\) { ⇒ \\{ } ⇒ \\} ^ ⇒ \\^ [ ⇒ \\[ ] ⇒ \\] 3. 자바의 특수문자는 \을 쓴다. " ⇒ \" 4. 나머지 부호들은 괜찮은 듯 하다. 확인된 것. ! # % & @ ` : ; - . , ~ '