gpt4 book ai didi

java - 如何分割字符串并存储到变量中以供将来使用?

转载 作者:行者123 更新时间:2023-12-02 13:25:10 25 4
gpt4 key购买 nike

我有一个 Android 应用程序,可以从 Excel 文件接收数据。我使用库将文本从 excel 获取到 textView。我收到的 excel 中始终有 3 列。因此,我想将收到的字符串分成 3 个位置,以便将 excel 提供的信息保存在 sqlite 中,并将它们放入 sqlite 数据库的相应行中。我想知道如何进行正确的字符串分割和存储的信息。 This is the output of the app now that receives from the excel感谢您的提前帮助。

try {

AssetManager am=getAssets();
InputStream is=am.open("Book1.xls");
Workbook wb =Workbook.getWorkbook(is);
Sheet s=wb.getSheet(0);
int row =s.getRows();
int col=s.getColumns();
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";
//here I want to divide this string in three positions


}
xx=xx+"\n";




}
textView.setText(xx);
}

catch (Exception e)
{

}

最佳答案

你想要这样的东西吗?

    String[] result = myString.split(" ");
String a = result[0];
String b = result[1];
String c = result[2];

关于java - 如何分割字符串并存储到变量中以供将来使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43411047/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com