반응형
1. split
String str = "sukeun.park, ,010-0000-0000";
String [] values = "str.split(",")";
for( int x = 0; x < values.length; x++ ){
System.out.println( "문자(열) " + (x+1) + " : " + values[x] );
}
print>
문자(열) 1 : sukeun.park
문자(열) 2 :
문자(열) 3 : 010-0000-0000
2. StringTokenizer
String str = "sukeun.park, ,010-0000-0000";
StringTokenizer tokens = new StringTokenizer(str, ",");
for(int x = 1; tokens.hasMoreElements(); x++;){
System.out.println( "문자(열) " + x + " : " + tokens.nextToken());
}
print>
문자(열) 1 : sukeun.park
문자(열) 2 : 010-0000-0000
차이점 알겠나?
String str = "sukeun.park, ,010-0000-0000";
String [] values = "str.split(",")";
for( int x = 0; x < values.length; x++ ){
System.out.println( "문자(열) " + (x+1) + " : " + values[x] );
}
print>
문자(열) 1 : sukeun.park
문자(열) 2 :
문자(열) 3 : 010-0000-0000
2. StringTokenizer
String str = "sukeun.park, ,010-0000-0000";
StringTokenizer tokens = new StringTokenizer(str, ",");
for(int x = 1; tokens.hasMoreElements(); x++;){
System.out.println( "문자(열) " + x + " : " + tokens.nextToken());
}
print>
문자(열) 1 : sukeun.park
문자(열) 2 : 010-0000-0000
차이점 알겠나?