Character라는 클래스에
public static int getType(char ch)
getType이라는 메소드가 문자값을 받아 character category값을 리턴해줍니다.
 
  String str = "dasjfl1ie ^&*으샤으샤 ㅁㄴ";
  for(int i=0;i<str.length();i++){
     if(Character.getType(str.charAt(i)) == 5) System.out.print("이건한글이넹 :: ");

     System.out.println(str.charAt(i));
  }

이런식으로 값을 찍어보면 한글의 경우는 5를 리턴합니다.
5가 리턴되면 무조건 한글이겠져..ㅎㅎㅎ


리턴되는 캐릭터 카테고리값들은 static으로 선언되어 있습니다.
COMBINING_SPACING_MARK, CONNECTOR_PUNCTUATION, CONTROL, CURRENCY_SYMBOL, DASH_PUNCTUATION, DECIMAL_DIGIT_NUMBER, ENCLOSING_MARK, END_PUNCTUATION, FORMAT, LETTER_NUMBER, LINE_SEPARATOR, LOWERCASE_LETTER, MATH_SYMBOL, MODIFIER_LETTER, MODIFIER_SYMBOL, NON_SPACING_MARK, OTHER_LETTER, OTHER_NUMBER, OTHER_PUNCTUATION, OTHER_SYMBOL, PARAGRAPH_SEPARATOR, PRIVATE_USE, SPACE_SEPARATOR, START_PUNCTUATION, SURROGATE, TITLECASE_LETTER, UNASSIGNED, UPPERCASE_LETTER

이값들을 체크해서 입력된 문자가 어떤 문자인지 체크가 가능합니다.
그리고 게시판 리스트의 제목을 보여줄때 한글일경우와 영문을 경우를 체크해서
제목테이블 사이즈 만큼 보여주는것도 가능하겠죠...^^


제가 메인화면에 게시글 리스트들을 보여줄때.. 제목의 길이가 길면
String message = a_data[i][1];
int sublen = 0;
StringBuffer sbuf = new StringBuffer();
for(int j=0;(j<message.length()&&sublen<35);j++){
         if(Character.getType(message.charAt(j)) == 5) sublen=sublen+2;//한글
         else sublen++;//기타 영문,특수문자,공백
         sbuf.append(message.charAt(j));
}
out.println(sbuf.toString()+"...");


문자열중에 한글의 갯수, 특수문자의 갯수.. 등등 원하는 문자만을 자를수도 있습니다.

Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

ResultSet rs = stmt.executeQuery("SELECT a, b FROM TABLE");


rs.last(); //ResultSet의 맨 끝의 행으로 이동...
int count = rs.getRow(); //현재로우가 맨마지막 로우므로 전체건수가된다...


java.sql.ResultSet API를 보시면 자세하게 설명이 나와있습니다..


TYPE_SCROLL_INSENSITIVE
The constant indicating the type for a ResultSet object that is scrollable
but generally not sensitive to changes made by others.


TYPE_SCROLL_SENSITIVE
The constant indicating the type for a ResultSet object that is scrollable
and generally sensitive to changes made by others.

(출처 : 'java ResultSet 에 대한 레코드 건수 알아내기' - 네이버 지식iN)



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

출처: http://java.sun.com/products/jdbc/reference/faqs/index.html


18. There is a method getColumnCount in the JDBC API. Is there a similar method to find the number of rows in a result set?

No, but it is easy to find the number of rows. If you are using a scrollable result set, rs, you can call the methods rs.last and then rs.getRow to find out how many rows rs has. If the result is not scrollable, you can either count the rows by iterating through the result set or get the number of rows by submitting a query with a COUNT column in the SELECT clause.


 

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


그러면 preparedStatement 에서는 어떻게 사용하는가..


   pstmt = conn.prepareStatement(sb.toString(),
      ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);

자바는 디렉토리가 비어 있지 않으면 삭제를 할 수 없으므로 재귀호출을 통하여

해당 디렉토리의 파일들을 먼저 지우고 디렉토리 삭제를 하도록 처리한당.. ^^


public static void deleteDir(String path) {
  deleteDir(new File(path));
 }

 

 public static void deleteDir(File file) {  

  if (!file.exists())
   return;

  File[] files = file.listFiles();
  for (int i = 0; i < files.length; i++) {
   if (files[i].isDirectory()) {
    deleteDir(files[i]);
   } else {
    files[i].delete();
   }
  }
  file.delete();
 }

+ Recent posts