한글을 포함한 글자수의 바이트를 구하는 유용한 함수.


// 바이트구하기
function getStringByte(s,b,i,c){
for(b=i=0;c=s.charCodeAt(i++);b+=c>>11?3:c>>7?2:1);
return b;
}



IntelliJ는 참좋은툴입니다.

vim에디터또한 제가정말 좋아하는 에디터이죠.

인텔리J에는 에디터를 vim화할수있는 ideavim이란 플러그인이 존재합니다.

하지만 vim플러그인에서 한글입력이 제대로 되지않는 문제가 있습니다.


이미 해당플러그인 개발자에게 보고도 되었습니다.

(https://youtrack.jetbrains.com/issue/VIM-764)

그러나 이 개발자님은 1년반이지나도록 수정을 안해주고있어서

정말 너무나도 답답한 나머지 수정 보았습니다.

(사실 여태껏 꺼놓고 쓰다가 

몇일전부터 너무 불편하여 수정을해서라도 고쳐보자 라는심정으로..)


이하소스는 임시해결방법일뿐이며 오작동할수도있고 문제가생겨도 저에게는책임이 없습니다.

또한 소스수정에있어 문제가 있을시 연락주시면 바로 내리도록하겠습니다.


간단하게

ideavim github레퍼지토리에서 소스를 다운받아 아래부분을 수정하고 빌드하여 쓰면됩니다.

플러그인개발구축환경은 구글링해보면 많이나오는관계로 따로 설명하지 않습니다.


com.maddyhome.idea.vim.VimTypedActionHandler 

위 자바파일의 execute함수부분을 수정합니다.


*기존

@Override
public void execute(@NotNull final Editor editor, final char charTyped, @NotNull final DataContext context) {
if (isEnabled(editor)) {
// Run key handler outside of the key typed command for creating our own undoable commands
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
handler.handleKey(editor, KeyStroke.getKeyStroke(charTyped), new EditorDataContext(editor));
}
catch (Throwable e) {
logger.error(e);
}
}
});
}
else {
origHandler.execute(editor, charTyped, context);
}
}



위부분에서 쓰레드부분을 아래와같이 바꿔줍니다.

*변경후

@Override
public void execute(@NotNull final Editor editor, final char charTyped, @NotNull final DataContext context) {
if (isEnabled(editor)) {
try {
handler.handleKey(editor, KeyStroke.getKeyStroke(charTyped), context);
}
catch (Throwable e) {
logger.error(e);
}
}
else {
origHandler.execute(editor, charTyped, context);
}
}


위 부분을 변경후 빌드하여 플러그인을 재설치하면됩니다.


0.30버전부터 해당증상이 나타난다는 댓글에서 힌트를얻어서

 0.29파일에서 사용된 로직입니다.


다시한번 임시해결방법임을 알려드립니다.

저는 사실 아주 귀찮기때문에 이부분이 왜 쓰레드처리로 변경되었는지는 알지도못하고 알아보고싶지도 않습니다.

하지만 한글사용에 있어 문제가된부분임은 확실해 보입니다.


해당플러그인 개발자님이 하루빨리 정식버전에서 고쳐주시기를 기다립니다.


끝.





보안상 특정IP만 허용 또는 제한할때 유용한 로직입니다.

와일드카드문자 또는 범위로 지정할수 있습니다.


/**
* check if IP address match pattern
*
* @param pattern
* *.*.*.* , 192.168.1.0-255 , *
* @param address
* - 192.168.1.1
* address = 10.2.88.12 pattern = *.*.*.* result: true
* address = 10.2.88.12 pattern = * result: true
* address = 10.2.88.12 pattern = 10.2.88.12-13 result: true
* address = 10.2.88.12 pattern = 10.2.88.13-125 result: false
* @return true if address match pattern
*/
public static boolean checkIPMatching(String pattern, String address)
{
if (pattern.equals("*.*.*.*") || pattern.equals("*"))
return true;

String[] mask = pattern.split("\\.");
String[] ip_address = address.split("\\.");
for (int i = 0; i < mask.length; i++)
{
if (mask[i].equals("*") || mask[i].equals(ip_address[i]))
continue;
else if (mask[i].contains("-"))
{
byte min = Byte.parseByte(mask[i].split("-")[0]);
byte max = Byte.parseByte(mask[i].split("-")[1]);
byte ip = Byte.parseByte(ip_address[i]);
if (ip < min || ip > max)
return false;
}
else
return false;
}
return true;
}


출처: http://www.java2s.com/Code/Java/Network-Protocol/CheckifIPaddressmatchpattern.htm



java.util.logging 을사용하여

간단한 자바프로그램에서 로그를 파일로 출력해본다.


1. logger객체 선언

private static final Logger logger = Logger.getLogger(MongoInsertTest.class.getName());


2. 파일핸들러 선언하고 포맷을 설정한다.

   (기본으로 출력하게되면 XML형식으로 지저분하게 출력되니깡~)

private FileHandler fileHandler;

try {

fileHandler = new FileHandler(System.currentTimeMillis()+MongoInsertTest.class.getName()+".log");


// 모든레벨의 로그를 출력한다.

LogRecord logRecord = new LogRecord(Level.ALL, "");


// 내용만 출력하도록 포맷을 재설정한다.

Formatter formatter = new Formatter() {

@Override

public String format(LogRecord record) {

String message = formatMessage(record);

message += "\n";

return message;

}

};

formatter.formatMessage(logRecord);


// 핸들러에 Formatter를 설정한다.

fileHandler.setFormatter(formatter);


} catch (SecurityException e) {

logger.log(Level.SEVERE, null, e);

} catch (IOException e) {

logger.log(Level.SEVERE, null, e);

}


3. logger객체에 핸들러를 추가한다.

logger.addHandler(fileHandler);


4. 사용한다.

logger.info( 내용 );



이렇게 하면 간단한 자바프로그램에서 로그를 쉽게 출력할수있다.



끝~



기존코드 <body style="background:none">  으로 하면 

IE9에서는 잘보이지만 그 이하버전 또는 호환성보기를 하면 아래와같이 배경이들어감




해결방법은


iframe에들어갈 문서 body태그에 아래를 추가

<body id="if_notice" style="background:transparent" >


iframe코드에 아래 속성 추가 

<iframe ...........................  allowTransparency="true">





완료.



끝.


원본코드

<button type="button" class="my_value" name="domainbtn" id="domainbtn"><span id="domainBtnName">JAEWOONG</span>

</button>

<ul>

<li><a href="javascript:changeDomain('<%=vDomain%>')"><%=vDomain %></a></li>      

</ul>


이라고 있을때 ul에 open스타일클래스를 먹이게되면 

아래그림과같이 버튼아래에 리스트가떠야한다.

단순히 select를 쓰면되겠지만 좀더깔끔한 디자인으로..






이럴때 ul에  <ul class="open"> 와같이 먹여야할때 쓰는코드.


jsp

<button type="button" class="my_value" name="domainbtn" id="domainbtn" onclick="javascript:openDomain()"><span id="domainBtnName">JAEWOONG</span>

</button>

<ul  id="domain_ul" >

<li> ......


javascript

function openDomain() {

var ul_obj = document.getElementById("domain_ul");

if (ul_obj.className == "open" ) {

ul_obj.className="";

} else {

ul_obj.className="open";

}

}




 

<HEAD>부분에 아래 자바스크립트를 삽입시킵니다.

<script language="javascript" type="text/JavaScript">
 function gogo_link() {
  if (window.opener && !window.opener.closed) {
   window.opener.location="주소를 입력합니다!";
   window.close();
  } else {
   alert("부모창이 닫혀있습니다");
  }
 }
</script>

 

링크를 겁니다

<a href="javascript:gogo_link();">GOGO</a>

 

 

끝납니다.


자바로 OS나 버전, 경로등 시스템정보를 알아내기



    System.out.println("OS["+ System.getProperty("os.name")+"]" );

    System.out.println("OS_VER["+ System.getProperty("os.version")+"]" );

    System.out.println("USER["+ System.getProperty("user.name")+"]" );

    System.out.println("File_Separator["+ System.getProperty("file.separator")+"]" );

    System.out.println("Path_Separator["+ System.getProperty("path.separator")+"]" );

    System.out.println("Current_working_dir["+ System.getProperty("user.dir")+"]" );




[결과값]

OS[AIX]

OS_VER[5.3]

USER[webmail]

File_Separator[/]

Path_Separator[:]

Current_working_dir[/was/webmail/myst/java_test]


파일내용은 (탭구분자, ANSI)

apple 사과

banana 바나나

kiwi 키위

subak 수박

melon 멜론

orange 오렌지




이것을 해시맵으로 읽어들여 키와 밸류를 출력시킨다.

static void jwtest() {

try {

BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("jwtest.txt"), "MS949"));

//BufferedReader br = new BufferedReader(new FileReader("jwtest.txt"));

String str ="";

Map<String, String> fruit = new HashMap<String, String>();

while ( (str = br.readLine()) != null ) {

String[] arr = str.split("\t");

fruit.put(arr[0], arr[1]);

}

Iterator kv = fruit.entrySet().iterator();

while(kv.hasNext()) {

Map.Entry entry = (Map.Entry) kv.next();

System.out.println(entry.getKey()+"__"+entry.getValue());

}

br.close();

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

}






1. 클래스 작성

package com.jw.customized.sync;


import org.apache.commons.logging.Log;

import org.apache.commons.logging.LogFactory;

import org.quartz.JobExecutionContext;

import org.quartz.JobExecutionException;

import org.quartz.StatefulJob;

import org.springframework.scheduling.quartz.QuartzJobBean;


import com.jw.customized.migration.DeptMigration;


public class SyncJob extends QuartzJobBean implements StatefulJob {

private static final Log logger = LogFactory.getLog(SyncJob.class);

private DeptMigration deptMigration = null;

public DeptMigration getDeptMigration() {

return deptMigration;

}


public void setDeptMigration(DeptMigration deptMigration) {

this.deptMigration = deptMigration;

}


@Override

protected void executeInternal(JobExecutionContext jobexecutioncontext)

       throws JobExecutionException {

if (this.deptMigration != null) {

if (this.deptMigration.isDoingExecute()) {

logger.warn("실행중입니다.");

} else {

this.deptMigration.execute();

}

}

}

}



2. xml에 설정하고 Quartz 설정

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">

<beans default-init-method="initialize">


.....

.....


        <bean id="migration.DeptMigration" class="com.jw.customized.migration.DeptMigration">

                <property name="dbConnectionManager"><ref bean="datasource.DBConnectionManager" /></property>

        </bean>

    <!-- scheduler -->
        <bean name="SchedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
                <property name="triggers">
                        <list>
                                <ref bean="sync.DeptMigrationJob.trigger" />
                        </list>
                </property>
                <property name="configLocation"><value>classpath:quartz.properties</value></property>
        </bean>
        <bean name="sync.DeptMigrationJob" class="org.springframework.scheduling.quartz.JobDetailBean">
                <property name="jobClass" value="com.jw.customized.sync.SyncJob" />
                <property name="jobDataAsMap">
                        <map>
                                <entry key="deptMigration"><ref bean="migration.DeptMigration" /></entry>
                        </map>
                </property>
        </bean>
        <bean id="sync.DeptMigrationJob.trigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<!--
  SimpleTriggerBean : 몇분마다 실행....
      __ property로 repeatInterval 을 갖음
  CronTriggerBean : 정기적 실행( 매시 언제..이런식)
      __ property로 cronExpression을 갖음
-->
                <!-- see the example of method invoking job above -->
                <property name="jobDetail" ref="sync.DeptMigrationJob" />
                <!-- 매일 02:20, 12/20 분에 수행  -->
                <property name="cronExpression" value="0 20 2,12 * * ?" />
        </bean>
</beans>


'업무 > Java' 카테고리의 다른 글

[java] 시스템정보 알아내기  (0) 2012.06.22
[java] 파일에서 읽어 맵에저장  (0) 2012.06.11
[java] euc-kr , utf-8 인코딩 변환  (0) 2012.04.30
[java] hashtable 사용  (0) 2012.02.08
[java] 파일 읽기  (0) 2012.02.08

간단히



String euckr = “가나다”;  // EUC-KR

String utf8 = new String(eucStr.getBytes(“euc-kr”), “utf-8″);


'업무 > Java' 카테고리의 다른 글

[java] 파일에서 읽어 맵에저장  (0) 2012.06.11
[java] Spring 스케줄러, QuartzJobBean  (0) 2012.05.21
[java] hashtable 사용  (0) 2012.02.08
[java] 파일 읽기  (0) 2012.02.08
[java] 파일 실행해서 출력시키기  (0) 2012.02.07

펄의 해쉬처럼 자바에서도 쓸수있다.

Hashtable


다음은 파일로부터 읽어와 키와 밸류쌍으로 해쉬테이블을 구성하고 출력하는 코드이다.

불러올 파일(WEB.log)의 내용은

#***** PROCESS DATE : 20120207 15:48

#***** FINISH!(WEB) *****

SEND_SUCCESS:4

CHANGE_STATUS:2

CONFIRM!_CHECK:30

DRAFT_SEND_SUCCESS:8

FOLDERSHARE_ADD:1

MBOX_CLEAN:20

LOGIN:21

ADDRBOOK_FAST_GROUP_ADD:1

MAIL_VIEW:33

PADDRBOOK_GROUP_REMOVE:1

SHAREFOLDER_MAIL_COPY:1

MAIL_REMOVE:2

이런식으로 되어있고 로그명은 키, 카운트는 밸류로 구성한다.



        private Hashtable<String,String> get_log_file() {

                Hashtable<String,String> logset = new Hashtable<String,String>();

                try {

                        BufferedReader in = new BufferedReader(new FileReader("/home/webmail/myst_export_log/record/WEB.log"));

                        String s;

                        while ((s = in.readLine()) != null) {

                                if (s.equals("") || s.charAt(0) == '#') { continue; }  //라인이 공백이거나 첫글자가 #이면 패스

                                String temp[] = s.split(":");

                                logset.put(temp[0], temp[1]); // logset에 넣음

                        }

                        in.close();

                } catch (IOException e) {

                        e.printStackTrace();

                }


                //출력하기

              Enumeration en = logset.keys();

              while (en.hasMoreElements()) {

                      String key = en.nextElement().toString();

          System.out.println(key + " :::: "+logset.get(key));

              }

              return logset;

        }


'업무 > Java' 카테고리의 다른 글

[java] Spring 스케줄러, QuartzJobBean  (0) 2012.05.21
[java] euc-kr , utf-8 인코딩 변환  (0) 2012.04.30
[java] 파일 읽기  (0) 2012.02.08
[java] 파일 실행해서 출력시키기  (0) 2012.02.07
[java] 파일 존재여부 판단  (0) 2012.02.07

파일 라인단위로 읽어서 출력합니다.


import! java.io.*;

-------------------------------

try{

    BufferedReader in = new BufferedReader(new FileReader("/home/webmail/test.txt"));

    while ( (String s = in.readLine()) != null ) {

        System.out.println(s);

    }

    in.close();

} catch (IOException e) {

    e.printStackTrace();

}


'업무 > Java' 카테고리의 다른 글

[java] euc-kr , utf-8 인코딩 변환  (0) 2012.04.30
[java] hashtable 사용  (0) 2012.02.08
[java] 파일 실행해서 출력시키기  (0) 2012.02.07
[java] 파일 존재여부 판단  (0) 2012.02.07
[java] war 만들기 / 풀기  (0) 2012.02.06

외부 파일을 실행하여 실행결과를 출력합니다.


import! java.io.*;


public class File_EXE {


    public static void main(String[] args) {

        String s;

        try {

            String cmd = "/home/webmail/test/time_converter.pl -dtu 2012/02/08/00/00/00";


            Runtime rt= Runtime.getRuntime();

            Process oProcess = rt.exec(cmd);


            BufferedReader stdOut = new BufferedReader(new InputStreamReader(oProcess.getInputStream()));

            BufferedReader stdErr = new BufferedReader(new InputStreamReader(oProcess.getErrorStream()));


            while( (s = stdOut.readLine()) != null) System.out.println(s);

            while( (s = stdErr.readLine()) != null) System.out.println(s);

        } catch (Exception e) {

            e.printStackTrace();

            System.exit(-1);

        }

    }

}



'업무 > Java' 카테고리의 다른 글

[java] hashtable 사용  (0) 2012.02.08
[java] 파일 읽기  (0) 2012.02.08
[java] 파일 존재여부 판단  (0) 2012.02.07
[java] war 만들기 / 풀기  (0) 2012.02.06
[javascript] input 태그  (0) 2012.01.30

*파일 존재여부

import! java.io.*;

==============================

File f = new File("파일명.txt");


if (f.isFile() ) {

    //존재할때

} else {

    // 존재안할때

}


*디렉토리 존재여부

import! java.io.*;

==============================

File d = new File("dir명");


if ( d.isDirectory() ) {

    //존재할때

} else {

    // 존재안할때

}



'업무 > Java' 카테고리의 다른 글

[java] 파일 읽기  (0) 2012.02.08
[java] 파일 실행해서 출력시키기  (0) 2012.02.07
[java] war 만들기 / 풀기  (0) 2012.02.06
[javascript] input 태그  (0) 2012.01.30
[eclipse] 매개변수  (0) 2011.12.20


*war 만들기

jar cvf test.war *



*war 풀기

jar xvf test.war



'업무 > Java' 카테고리의 다른 글

[java] 파일 읽기  (0) 2012.02.08
[java] 파일 실행해서 출력시키기  (0) 2012.02.07
[java] 파일 존재여부 판단  (0) 2012.02.07
[javascript] input 태그  (0) 2012.01.30
[eclipse] 매개변수  (0) 2011.12.20

input 태그 총정리 

1. <input> : 평범하게 글자나 텍스트칸을 넣을 수있는 공간이 생기죠.
2. <input type=""> : 기존의 input에다가 type를 지정하여 type의 옵션을 넣으면, 
다양한 모양이 됩니다. 단 입력이나 기타 등등의 모양 꼴로 변하죠.

3. <input type="text"> : 이건 <input>과 동일한 것인데, text를 넣을 수 있습니다.
4. <input type="password">: 이건 1번과 2번과 3번과 동일한데, 비밀번호로 지정되어 글자를 넣든 숫자를 넣든 **** <-이렇게 표시됩니다.

4. <input type="checkbox"> : 이건 체크박스로 나타납니다.
5. <input type="checkbox" checked> : 이건 체크박스의 선택된 것으로 나오죠.
6. <input type="checkbox" checked disabled> : 이건 체크되었다가 다시는 선택 못하게 하는거죠

7. <input type="radio"> : 이건 라디오 버튼으로 나타납니다.
8. <input type="radio" checked> : 이건 라디오 버튼의 선택된 것으로 나오죠.
9. <input type="radio" checked disabled> : 이건 선택되었다가 다시는 선택 못하게 하는거죠

10. <input type="hidden"> : 이건 숨김필드입니다. 값을 넘겨받을때 숨김속성으로 몰래 감춰지죠. 
대부분 form태그의 중요한 속성을 사용할 때 하더군요.

11. <input type="image" src="이미지 경로및 주소"> 이건 이미지의 경로를 넣어 일반<img>태그 처럼 할 수 있습니다. 
단 버튼이 이미지의 경로로 바뀌고,form 태그의 submit 태그와 함께 포함되어 있습니다.

12. <input type="reset"> : 이건 초기화 하는 버튼(영어로 submit 또는 초기화라고 나옴)
13. <input type="reset" value="초기화"> :  value값에 초기화라고하면 초기화라고 만들어줌

14. <input type="submit"> : 이건 전송버튼
15. <input type="submit" value="전송함"> : 전송버튼인데다가 버튼이름을 전송함 이라고 할 수있음.
16. <input type="file"> : 파일을 첨부할 때 사용하며, CSS와 곁들어서 사용 가능

'업무 > Java' 카테고리의 다른 글

[java] 파일 읽기  (0) 2012.02.08
[java] 파일 실행해서 출력시키기  (0) 2012.02.07
[java] 파일 존재여부 판단  (0) 2012.02.07
[java] war 만들기 / 풀기  (0) 2012.02.06
[eclipse] 매개변수  (0) 2011.12.20

업무용..

-Xms256m -Xmx512m -XX:MaxPermSize=256m

'업무 > Java' 카테고리의 다른 글

[java] 파일 읽기  (0) 2012.02.08
[java] 파일 실행해서 출력시키기  (0) 2012.02.07
[java] 파일 존재여부 판단  (0) 2012.02.07
[java] war 만들기 / 풀기  (0) 2012.02.06
[javascript] input 태그  (0) 2012.01.30

+ Recent posts