블로그 이미지
박공명

카테고리

분류 전체보기 (99)
된장 (7)
Dev (60)
꼐..꼐임 (6)
식탐 (18)
우리 (0)
Etc (8)
개인자료 (0)
Total
Today
Yesterday

Full GC

Dev/Java / 2010. 3. 25. 15:08
이미지 리사이징 기능 수행시 웹로직에서는 이런 로그가 나타난다.
운영쪽에서는 자주나온다고 에러로 취급하는 느낌이다.

: 61982K->53561K(321536K), 0.4544700 secs] 185048K->53561K(505856K), [Perm : 108413K->108413K(131072K)], 0.4545180 secs]
1753432.930: [Full GC 1753432.930: [Tenured: 53561K->37065K(321536K), 0.4244530 secs] 57523K->37065K(505856K), [Perm : 108413K->98056K(131072K)], 0.4245010 secs]
1753433.442: [Full GC 1753433.442: [Tenured: 37065K->37106K(321536K), 0.3641750 secs] 38464K->37106K(505856K), [Perm : 98056K->98056K(131072K)], 0.3642220 secs]
1753433.834: [Full GC 1753433.834: [Tenured: 37106K->37218K(321536K), 0.3640000 secs] 37279K->37218K(505856K), [Perm : 98056K->98056K(131072K)], 0.3640450 secs]
1753434.243: [Full GC 1753434.243: [Tenured: 37218K->37367K(321536K), 0.3639820 secs] 37556K->37367K(505856K), [Perm : 98056K->98056K(131072K)], 0.3640280 secs]
1753434.644: [Full GC 1753434.644: [Tenured: 37367K->35407K(321536K), 0.3645940 secs] 37714K->35407K(505856K), [Perm : 98056K->98056K(131072K)], 0.3646390 secs]


ImageIO.write() 메소드가 실행될때 System.gc() 와같은게 같이 작용되는모양인데
뭐가 에러고 뭘 고쳐야할진 아직 모르겠군.

'Dev > Java' 카테고리의 다른 글

자바 컴파일 클래스패스 지정  (0) 2010.04.01
java.sql.SQLException: 스트림이 이미 종료되었습니다  (0) 2010.03.25
ftp upload  (0) 2010.03.24
ftp 파일삭제.  (0) 2010.03.24
정규표현식을 사용하여 스크립트 제거  (1) 2010.03.24
Posted by 박공명
, |

ftp upload

Dev/Java / 2010. 3. 24. 18:12


import sun.net.ftp.FtpClient;
import java.io.FileOutputStream;
import sun.net.TelnetOutputStream;
import java.io.IOException;
import sun.net.TelnetInputStream;
import java.io.FileInputStream;
import java.util.zip.*;
import java.util.*;
import java.io.*;

 public boolean doUpLoad(String mode,String s_server,String userid,String passwd) {
  FtpClient ftpClient = new FtpClient();
  TelnetOutputStream os =null ;
  FileInputStream is = null;
  try {
   
   System.out.println("doUpload in");
   ftpClient.openServer(s_server);
   System.out.println("server open");
   ftpClient.login(userid, passwd);
   System.out.println("server login");
   if (serverPath.length() != 0)
    ftpClient.cd(serverPath);
   //System.out.println("-4");
   if("asc".equals(mode)) 
    ftpClient.ascii();
   else
    ftpClient.binary();
   //System.out.println("-5");
   if("".equals(serverFile)) {
    serverFile =  localFile ;
   }
   System.out.println("write file path = " + serverPath+"/"+serverFile);
   os = ftpClient.put(serverPath +"/"+ serverFile );
   System.out.println("read file path = " + localPath+"/"+localFile);
   File file_in = new File(localPath+"/"+localFile);
   is = new FileInputStream(file_in);
   byte[] bytes = new byte[1024];
   int c;
   while ((c = is.read(bytes)) != -1) {
    os.write(bytes, 0, c);
   }
   System.out.println("doUpload complete");
   
   is.close();
   os.close();
   ftpClient.closeServer();
   System.out.println("doUpload close server");
   return true;
  }catch (IOException ie) {
   ie.printStackTrace();
   System.out.println("FTP Exeception -----" + ie.getMessage());
   return false;
  }catch(Exception e){
   e.printStackTrace();
   System.out.println("FTP Exeception -----" + e.getMessage());
   return false;
  }finally{
   try{
    is.close();
    os.close();
    ftpClient.closeServer();
   }catch(Exception e){} 
  }
 }


ㅇㅇㅇ

file.delete(); 만 추가하면 upload 가 아니구 move가 되겠지

'Dev > Java' 카테고리의 다른 글

java.sql.SQLException: 스트림이 이미 종료되었습니다  (0) 2010.03.25
Full GC  (0) 2010.03.25
ftp 파일삭제.  (0) 2010.03.24
정규표현식을 사용하여 스크립트 제거  (1) 2010.03.24
이미지 리사이징 , image resize  (0) 2010.03.24
Posted by 박공명
, |

ftp 파일삭제.

Dev/Java / 2010. 3. 24. 16:21

ftp기능을 만지다보니 생각지도못하게

원격지파일 삭제기능을 지원하는 라이브러리가 없는거 같더라.

뭐 내가 못찾았을수도 있고...

한 4가지를 모두 사용해보구 되는거 한개를 찾았다.

org.apache.commons.net.ftp.FTP

아파치꺼네


public void deleteFtp() throws Exception {
  
    FTPClient client = null;
    BufferedInputStream bis = null;
    try {
     client = new FTPClient();

  client.setControlEncoding("euc-kr");
  client.connect(server , Integer.parseInt(port));
  int resultCode = client.getReplyCode();
  
  if(FTPReply.isPositiveCompletion(resultCode) == false){
   throw new Exception("FTP 서버에 연결할 수 없습니다.");
  }
  else {
   client.setSoTimeout(5000);
   boolean isLogin = client.login(user, password1);
   if(isLogin == false) {
    throw new Exception("FTP 서버에 로그인 할 수 없습니다.");
   }
   client.setFileType(FTP.BINARY_FILE_TYPE);
   String deleteFile = serverPath + "/" + serverFile;
   System.out.println("delete path = " + deleteFile);
  boolean delflag =  client.deleteFile(deleteFile);
  //System.out.println("파일 전송 성공여부 : "+isSuc);
  if(delflag == false) {
   throw new Exception("파일삭제에 실패 하였습니다.");
  }
 
      client.logout();
     }
    } catch (Exception e) {
     e.printStackTrace();
     throw e;
    }
    finally {
    
     if(bis != null) {
      try {bis.close(); } catch (Exception e) { }
     }
     if(client != null && client.isConnected()) {
      try { client.disconnect(); } catch (Exception e) {}
     }
    }
   
   }


단지 파일삭제기능을 수행하는 메소드가 필요할뿐인데 왜 다른데서는 못찾았을까??? 정말없나?

'Dev > Java' 카테고리의 다른 글

java.sql.SQLException: 스트림이 이미 종료되었습니다  (0) 2010.03.25
Full GC  (0) 2010.03.25
ftp upload  (0) 2010.03.24
정규표현식을 사용하여 스크립트 제거  (1) 2010.03.24
이미지 리사이징 , image resize  (0) 2010.03.24
Posted by 박공명
, |

import java.util.regex.*;
이놈이 필요하다.

 public String getRemoveScript(String strContent){
  if(strContent == null) strContent = "";
  Pattern patternTag=Pattern.compile("\\<(\\/?)(\\w+)*([^<>]*)>");
  Pattern patternScript=Pattern.compile("(?i)\\<script(.*?)</script>");
  Pattern patternMouseOver=Pattern.compile("(?i) onmouseover=[\"']?([^>\"']+)[\"']*");
  Pattern patternMouseOut=Pattern.compile("(?i) onmouseout=[\"']?([^>\"']+)[\"']*");
  Pattern patternMouseClick=Pattern.compile("(?i) onclick=[\"']?([^>\"']+)[\"']*");
  Matcher matcherContent=patternScript.matcher(strContent);
  strContent=matcherContent.replaceAll("");
  Matcher matcherMouseOver=patternMouseOver.matcher(strContent);
  strContent=matcherMouseOver.replaceAll("");
  Matcher matcherMouseOut=patternMouseOut.matcher(strContent);
  strContent=matcherMouseOut.replaceAll("");
  Matcher matcherMouseClick=patternMouseClick.matcher(strContent);
  strContent=matcherMouseClick.replaceAll("");
  return strContent;
 }

원하는 표현식을 제거할수있다.

프레임웍같은걸 안쓰니깐 여러가지 신경써야할것이 많다.

자바스크립트 전문가와 함께있으니 배우는게 많구나 ㅋㅋㅋ

'Dev > Java' 카테고리의 다른 글

java.sql.SQLException: 스트림이 이미 종료되었습니다  (0) 2010.03.25
Full GC  (0) 2010.03.25
ftp upload  (0) 2010.03.24
ftp 파일삭제.  (0) 2010.03.24
이미지 리사이징 , image resize  (0) 2010.03.24
Posted by 박공명
, |



리사이징에는 jai 도 필요 없더이다..

출처는 잘 모르겠구 jai로했을때는 사이즈가 변할때 깨지는일이 있었는데

이건 갠찬네.

사이즈 변경안할때 이미지가 아닌것을 넣으면 널포인트 난다는것에 주의하자.

참 쉽쥬?


import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.ImageIcon;

// com.sun.image.codec.jpeg package is included in sun and ibm sdk 1.3
import com.sun.image.codec.jpeg.*;

public class ImageUtil{
 public static final int RATIO = 0;
 public static final int SAME = -1;
 
 public  void resize(File src, File dest, int width, int height) throws IOException {
  Image srcImg = null;
  String suffix = src.getName().substring(src.getName().lastIndexOf('.')+1).toLowerCase();
  if (suffix.equals("bmp") || suffix.equals("png") || suffix.equals("gif")) {
   srcImg = ImageIO.read(src);
  } else {
   // BMP가 아닌 경우 ImageIcon을 활용해서 Image 생성
   // 이렇게 하는 이유는 getScaledInstance를 통해 구한 이미지를
   // PixelGrabber.grabPixels로 리사이즈 할때
   // 빠르게 처리하기 위함이다.
   srcImg = new ImageIcon(src.toURL()).getImage();
  }
  
  int srcWidth = srcImg.getWidth(null);
  int srcHeight = srcImg.getHeight(null);
  
  int destWidth = -1, destHeight = -1;
  
  if (width == SAME) {
   destWidth = srcWidth;
  } else if (width > 0) {
   destWidth = width;
  }
  
  if (height == SAME) {
   destHeight = srcHeight;
  } else if (height > 0) {
   destHeight = height;
  }
  
  if (width == RATIO && height == RATIO) {
   destWidth = srcWidth;
   destHeight = srcHeight;
  } else if (width == RATIO) {
   double ratio = ((double)destHeight) / ((double)srcHeight);
   destWidth = (int)((double)srcWidth * ratio);
  } else if (height == RATIO) {
   double ratio = ((double)destWidth) / ((double)srcWidth);
   destHeight = (int)((double)srcHeight * ratio);
  }
  Image imgTarget = srcImg.getScaledInstance(destWidth, destHeight, Image.SCALE_SMOOTH);
  int pixels[] = new int[destWidth * destHeight];
  PixelGrabber pg = new PixelGrabber(imgTarget, 0, 0, destWidth, destHeight, pixels, 0, destWidth);
  try {
   pg.grabPixels();
  } catch (InterruptedException e) {
   throw new IOException(e.getMessage());
  }
  BufferedImage destImg = new BufferedImage(destWidth, destHeight, BufferedImage.TYPE_INT_RGB);
  destImg.setRGB(0, 0, destWidth, destHeight, pixels, 0, destWidth);
  ImageIO.write(destImg, "jpg", dest);
 }

 public  int getHeight(String strImage,int intMaxWidth){
  Image imgSrc=new ImageIcon(strImage).getImage();
  return imgSrc.getHeight(null)*intMaxWidth/imgSrc.getWidth(null);
 }

}

'Dev > Java' 카테고리의 다른 글

java.sql.SQLException: 스트림이 이미 종료되었습니다  (0) 2010.03.25
Full GC  (0) 2010.03.25
ftp upload  (0) 2010.03.24
ftp 파일삭제.  (0) 2010.03.24
정규표현식을 사용하여 스크립트 제거  (1) 2010.03.24
Posted by 박공명
, |

사구싶습니다.

Dev/Android / 2010. 3. 23. 23:31

넵 여자친구보다 이쁘군요.



물론 여자친구는 없습니다.

'Dev > Android' 카테고리의 다른 글

LG Real 3D SDK  (1) 2011.04.13
JNI ?  (1) 2010.10.28
안드로이드 교육내용  (0) 2010.09.13
이클립스에서 안드로이드 프로젝트에 이유없는 에러표시  (0) 2010.06.16
안드로이드 세팅  (0) 2010.04.13
Posted by 박공명
, |

이미지 리사이징 기능을 만들던 도중

윈도우 / 톰캣 환경에서는 되던 리사이즈 기능이

유닉스 / 웹로직 환경에서 에러가나는것을 확인하였다.



이유를 찾앙본즉슨 awt 객체가 이미지를 생성하며 화면 키보드 마우스의 자원을 사용하지않음에도 불구하고

내부적으로 가져오도록 되있다는것이다.  뭐 어쨋든 버그에 가깝다는 것

해결책은 간단하다.

시대가 시대인만큼 자바 1.4 이상에서만 통용되는 방법을 적어야지.

-Djava.awt.headleass=true

자바나,웹로직 구동옵션에 추가시켜주면 된다. 아주 잘된다.

귀중한 정보를 도움주신분들 링크정돈 달아놔야겠다
http://blog.naver.com/galahad76?Redirect=Log&logNo=20042609592
http://blog.naver.com/swanjooo?Redirect=Log&logNo=60001512307


Posted by 박공명
, |
request 객체를 사용하다가 get방식의 파라메터를 모두 포함한 주소를 뽑아내고 싶었던적이 있었는데
그걸 찾을수가 없더이다.. 검색실력이 달리나?
그래서 고민을 했더니 두리형이 기냥 만들어버렸다. 자 잠깐 나두 해보구싶었다규

String URI = request.getRequestURI();
String strQuery="";
Enumeration enum = request.getParameterNames();
while(enum.hasMoreElements()) { 
 String key = (String)enum.nextElement();
 String value = request.getParameter(key);
 strQuery+="&"+key+"="+value;
}
strQuery=URI+ "?" + strQuery.substring(1);

이렇게하면 request에서 뽑아낸 주소에 파라메터를 다시 합체해서 원래주소를 만들수 있겠죠?

'Dev > JSP' 카테고리의 다른 글

getRealPath() , 절대경로 가져오기  (1) 2010.03.25
쿠키 설정  (0) 2010.03.23
Posted by 박공명
, |

쿠키 설정

Dev/JSP / 2010. 3. 23. 22:29

더이상 설명이 필요없군.,

String seqDesigner = request.getParameter("seq");
Cookie cookie = new Cookie("seqDesigner" , seqDesigner);
cookie.setMaxAge(60*60*24);
cookie.setPath("/");
response.addCookie(cookie);
System.out.println("Create Cookie cookie name = seqDesigner  value = " + seqDesigner);



 String cookiename = "";
 String cookievalue = "";
 Cookie cookie[] = request.getCookies();
 if(cookie != null) {
  for(int i=0;i<cookie.length;i++) {
   System.out.println("cookie name = " + cookie[i].getName());
   if(cookie[i].getName().equals("seqDesigner")) {
    cookiename = cookie[i].getName();
    cookievalue = cookie[i].getValue();
   }
  }
 }
Posted by 박공명
, |

가우스 라이센스

Dev/Gauce / 2010. 3. 23. 22:04

아마 정식 사용자가 아니면 매달 1일 라이센스를 받아야 한다.

시스템은 정식 쓰는 모양인데 왜 시스템관리자는 ㅋㅋㅋㅋㅋㅋㅋ 뭥미





까짓거 해당 경로에 있는 라이센스 파일을 열어서 편집 해주면 ㅇㅋ
Posted by 박공명
, |

최근에 달린 댓글

최근에 받은 트랙백

글 보관함