,因爲我已經包含文本的文本文件:解析txt文件數據
VOLT=367
CURRENT=0.07
TEMP=031
RPM=3780
63HZ
VOLT=288
CURRENT=0.00
TEMP=030
RPM=3420
57HZ
等等.... 我想利用這個文本文件作爲Java輸入和創建一個輸出的文本文件具有這種文字排列爲:
367,0.07,031,3780,63
288,0.00,030,3420,57
依此類推,直到txt文件的末尾..
編碼嘗試至今:
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
try {
FileInputStream fstream = new FileInputStream("file path\data.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
BufferedWriter brw = new BufferedWriter(new OutputStreamWriter(out));
do {
for (int i=1;i<50;i++) {
//I dont know what to do here
...
我是新來java..so我只知道如何逐行閱讀這個文本文件使用bufferedreader..but但我不知道如何輸出dat到文本文件::我使用... –
import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.InputStreamReader; 嘗試FileInputStream fstream = new FileInputStream(「file path \ data.txt」); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); BufferedWriter brw = new BufferedWriter(new OutputStreamWriter(out)); 做{ 的for(int i = 1; I <50;我++){// 我不知道這裏做什麼 } ....... –
更新這在你的問題 – newuser