Android 解析CSV 文件,如何在Android Studio中将CSV文件解析为数组

14

Where to put the CSV file in Android Create a folder named “raw” inside the “res” folder and put the CSV file in it.

将CSV文件放在Android中的位置在“res”文件夹中创建名为“raw”的文件夹并将CSV文件放入其中。

How to read CSV file, Nothing special since its Android. All we are going to use our standard Java code. Its better to use our own code instead of going to an API. Following class is an utility to read CSV file and it can be used from within the Android application. In which array we will store items of csv file In these example it is scorelist arraylist .

如何阅读CSV文件,自Android以来没什么特别之处。我们将使用我们的标准Java代码。最好使用我们自己的代码而不是使用API​​。下面的类是一个读取CSV文件的实用程序,它可以在Android应用程序中使用。我们将在哪个数组中存储csv文件的项目。在这些示例中,它是scorelist arraylist。

public class CSVFile {

InputStream inputStream;

public CSVFile(InputStream inputStream){

this.inputStream = inputStream;

}

public List read(){

List resultList = new ArrayList();

BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));

try {

String csvLine;

while ((csvLine = reader.readLine()) != null) {

String[] row = csvLine.split(",");

<
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值