你好,我正在做我的自定义条形码扫描仪,我几乎做了一切只需要帮助。csv文件自定义。我需要简单的代码,只允许或将扫描的代码号放在第一列A中,只将日期放在colmun B中。(我已经编写了脚本,可以正确地编写这两个值,但在水平方向上没有列分隔)
代码如下:
try {
File myFile = new File("/sdcard/data.csv");
myFile.createNewFile();
FileOutputStream fOut = new FileOutputStream(myFile, true);
OutputStreamWriter myOutWriter =
new OutputStreamWriter(fOut);
myOutWriter.append(scanContent);
Calendar c = Calendar.getInstance();
SimpleDateFormat dateformat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
String datetime = dateformat.format(c.getTime());
myOutWriter.append(datetime);
myOutWriter.close();
fOut.close();
Toast.makeText(MainActivity.this,
"File created'mysdfile.txt'",
Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Toast.makeText(MainActivity.this, e.getMessage(),
Toast.LENGTH_SHORT).show();