首页 > 解决方案 > 如何从字符串值在 android 中创建 CSV 文件

问题描述

如何在 android 中创建 CSV 文件,我正在获取字符串值。像 52 \n 21 \n 120 \n .... 等

我想为所有值创建一个 CSV 文件。

这是我获取字符串的代码。

 String msg = new String(data);



            if(newline.equals(TextUtil.newline_crlf) && msg.length() > 0) {
                // don't show CR as ^M if directly before LF
                msg = msg.replace(TextUtil.newline_crlf, TextUtil.newline_lf);
                // special handling if CR and LF come in separate fragments
                if (pendingNewline && msg.charAt(0) == '\n') {
                    Editable edt = receiveText.getEditableText();
                    if (edt != null && edt.length() > 1)
                        edt.replace(edt.length() - 2, edt.length(), "");
                }
                pendingNewline = msg.charAt(msg.length() - 1) == '\r';
            }
       
            receiveText.append(String.valueOf(TextUtil.toCaretString(msg, newline.length() != 0)));

标签: javaandroidandroid-studiocsv

解决方案


推荐阅读