Showing posts with label 자바. Show all posts
Showing posts with label 자바. Show all posts

2004-11-06

자바에서 한글 처리

1. ISO-8859-1에서 KSC5601로

String before = ...
String after = new String(before.getBytes("8859_1"),"KSC5601");


2. properties 파일에서 한글 읽기
 
(1) 1. 번 방식 사용
 
(2) native2ascii 도구 사용

native2ascii Before.poroperties After.properties

 
3. 주의 사항
 
(1) 이클립스에서 properties 파일 관리
 
속성에서 encoding을 MS949로 변경

2004-10-26

J2SE 1.4 Assertions

1. 프로그램 작성

Test.java

int month = ...

/* 메시지 없이 */
assert (month <13);

/* 메시지 포함 */
assert (month <13) : "The value of iMonth has exceeded 12";

메시지를 메서드 호출을 통해서 받을 수 있다. 단, 그 메소드는 void를 반환해서는 안된다.


2. 소스 컴파일

javac -source 1.4 Test.java


3. 프로그램 실행

java -enableassertions Test


4. Eclipse 3.0 설정

Java Compiler > Compliance and Classfiles 메뉴에서

Use default compliance settings 체크 박스를 비활성화하고 Generated .class files Compatibility와 Source Compatibility를 모두 1.4로 선택한다.