StringTokenizer example


===============================================
package testjava;

import java.io.File;
import java.util.StringTokenizer;

public class TStringTokenizer {


public static void main(String[] args) {
//The following is one example of the use of the tokenizer. The code:

File curDir ;
String fileName = "";
String chkFile = "";

try {
curDir = new File(System.getProperty("user.dir")+System.getProperty("file.separator")+"src"+System.getProperty("file.separator")+"testjava");
for(File f : curDir.listFiles()){
fileName = f.getName().toLowerCase();

StringTokenizer st =  new StringTokenizer(fileName , ".");
while(st.hasMoreTokens()){
st.nextToken();
if(st.countTokens()== 1){
chkFile = st.nextToken().toLowerCase();
}
}//while

if("jpg".equals(chkFile)||"jpeg".equals(chkFile))
System.out.println("ok jpg");
else
System.out.println("is not jpg : "+fileName);

}//for
} catch (Exception e) {
// TODO: handle exception
}
}

}
------------------------------------------------------------------
result :
is not jpg : inqueryelevatorvo.java
is not jpg : tstringtokenizer.java

Popular posts from this blog

youtube download

com.gpki.secureweb.GPKISecureWEBException: ErrCode=1507,ErrMsg=[GPKI_CMS_ProcessEnvelopedData] 해당 인증서로는 데이터를 풀 수 없습니다.

rexpert 공식필드(javascript) 점검일 주기 계산