2017-04-27 48 views
0

我在如何存儲包含的字符串;爲String []中的java

String x = "સ્થિતિ"; 
// WHich is Hex NCR cooded string contains & # x 0 and ; for e.g. &#x0AB ; 

String sFinalData = [email protected]~x~~~22~true 

我使用以下代碼輸入字符串。

String[] sPropertyString = sFinalData.split("@"); 
for(int iter=0;iter<sPropertyString.length;iter++){ 
    String[] sProperty = sPropertyString[iter].split("~"); 
    sPropertyName = sProperty[1]; 
    System.out.println("O/P..."+sPropertyName); 
} 

但是,對於上面的代碼,它顯示數組索引超出限制。

我需要將這個十六進制NCR字符串存儲到數據庫。

有什麼建議嗎?

+0

這個編輯器自動將HEX NCR轉換爲字,所以請考慮hexNCR代碼String x。 –

回答

0

sPropertyName = sProperty[1];是數組索引超出限制異常來自這一行嗎?爲什麼你使用索引1,也許sProperty.length是1.然後最大索引是0.

+0

因爲我想存儲HEXNCR代碼,我將從位置1的sProperty數組中獲取它。 –

+0

哪一行會拋出ArrayIndexOutOfBoundException? – wylasr

+0

sPropertyName = sProperty [1];拋出數組索引出界 –

相關問題