センサーからデータを収集し、収集したデータをプロット用のテキスト ファイルに保存する Android アプリケーションを作成しました。その後、他の目的のために、収集したデータを特定の形式でテキスト ファイルに保存する必要があります。次の形式のテキスト ファイル内のデータ:
1,34
2,40
3,56
4,66
.
.
.
... 等々。
ただし、データは次のように保存されます。
1,342 403 564 66
これが問題です。
書き込み関数は次のようになります。
public void writing_in_file_1(){
try{
//file_1.createNewFile();
fw = new FileWriter(file_1, true);
bw = new BufferedWriter(fw);
out = new PrintWriter(bw);
out.append(String.valueOf(time + "\t "+currentReading ) );
out.append("\n");
//out.append(String.valueOf(current_reading_list));
out.flush();
Toast.makeText(
this,
"Done writing SD 'specific text file'",
Toast.LENGTH_SHORT)
.show();
}
catch (IOException e) {
e.printStackTrace();
}
finally {
try {
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}