2017-04-14 59 views
-4

我已经做了一个string.split,然后调用数组的第一个位置,但出于某种原因,所有的数组结果都出现了。这是我的代码如何在java中进行分割?

try { 
    String xx = ""; 

    for (int i = 0; i < row; i++) { 
     for (int c = 0; c < col; c++) { 
      Cell z = s.getCell(c, i); 

      xx = xx + z.getContents() + "\n"; 
     } 

     xx = xx + "\n"; 

    } 
    //I do the split here but the result[0] = all the information 
    String result[] = xx.split(","); 
    textView.setText(result[0]); 
} catch (Exception e) { 

} 

这是输出的图像: Description of the output

+0

你不在'字符串'之间加''' –

+0

所以你能帮我吗? – jose

+0

'z.getContents()'返回的字符串格式是什么?举一个'String'的例子。 –

回答

0

尝试劈开\\\\。像

String exampleString = "A\\B\\C\\D"; //escaping the "\" character 
String array[] = exampleString.split("\\\\");