Programming/Android
String형 쪼개기
사천y
2011. 7. 12. 23:42
private void readData(String readMessage)
{
{
int[] Index = new int[3];
int j = 0;
String Data = readMessage;
String read;
//String에서 a를 검출하여서 Index배열에 처음과 끝을 저장
for( int i = 0; i < Data.length();i++)
{
if( Data.charAt(i) == 'a' )
{
Index[j] = i;
j++;
}
}
//read에 a의 시작과 끝 중간에 있는 문자를 넣는다
read = Data.substring(Index[0]+1, Index[1]);
Toast.makeText(Bluetooth.this, read, Toast.LENGTH_SHORT).show();
}
read = Data.substring(Index[0]+1, Index[1]);
Toast.makeText(Bluetooth.this, read, Toast.LENGTH_SHORT).show();
}