【问题标题】:Get query from a file text and insert to a database table从文件文本中获取查询并插入到数据库表中
【发布时间】:2015-06-24 12:54:01
【问题描述】:

我有一个文本文件,其中存储了 aliments 、quantity 和卡路里的列表,由“==”与数量和“===”与卡路里分隔,这是一个示例:

文件aliments.txt

Funghi Trifolati_ING == 200 G === 50
Funghi Trifolati_ING == 50 G === 12
Funghi Tritati_ING == 0 === 25
Funghi Tritati_ING == 100 G === 25
Funghi_ING == 0 === 25
Funghi_ING == 1 Cucchiaio === 10
Funghi_ING == 1 Manciata === 10

如何将食物、数量和卡路里放在表格的三个不同列中?

【问题讨论】:

    标签: java android mysql


    【解决方案1】:

    什么样的桌子?

    您应该 split 将您的字符串拆分为子字符串。

    String[] alimentAndRest = unsplitString.split("==");
    String aliment = alimentAndRest[0];
    String[] quantityAndCalories = alimentAndRest[1].split("===");
    String quantity = quantityAndCalories[0];
    String calories = quantityAndCalories[1];
    

    【讨论】:

    • 好的,现在我把数据库放到asset文件夹里了,我怎样才能找回数据呢?
    • 好的,谢谢,但我不明白如何从我的 db 文件中检索 unsplitstring,您能帮帮我吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-27
    • 1970-01-01
    • 2010-12-02
    • 1970-01-01
    • 2014-08-17
    相关资源
    最近更新 更多