336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
public class Test
{
public static void main(String[] args)
{
String text = "AAA BBB CCC DDD EEE FFF";
int count = 0;
for (int i = 0; i < text.length(); i++)
{
if (text.charAt(i) == ' ')
{
count++;
} else
{
}
}
String[] textResult = new String[count + 1];
int i, j, k;
for (i = 0; i < text.length(); i++)
{
if (text.charAt(i) == ' ')
{
textResult[0] = text.substring(0, i);
break;
}
}
System.out.print(textResult[0]);
int lastValue = 0;
for (k = 1; i < text.length(); k++)
{
i = i + 1;
j = i;
for (; i < text.length(); i++)
{
if (text.charAt(i) == ' ')
{
System.out.print("\n");
textResult[k] = text.substring(j, i);
lastValue = i;
break;
}
}
}
textResult[k-1] = text.substring(lastValue+1 , text.length() );
for( String s : textResult )
{
System.out.println(s);
}
}
}
시스템 라이브러리를 활용
public class Test
{
public static void main(String[] args)
{
String text = "AAA BBB CCC DDD EEE FFF";
StringTokenizer st = new StringTokenizer(text, " ");
while(st.hasMoreTokens() )
{
System.out.println(st.nextToken());
}
}
}
'Programming > JAVA,JSP' 카테고리의 다른 글
| JAVA 계산기 레이아웃 (0) | 2013.08.16 |
|---|---|
| JAVA 타자연습 프로그램 (0) | 2013.08.13 |
| JAVA 제네릭을 사용한 Store Class (0) | 2013.08.07 |
| JAVA DRAG 가능한 Component 만들기 (0) | 2013.08.03 |
| JAVA Swing 두개의 판넬을 겹치기 (0) | 2013.08.03 |

