0
我的代碼確實讀取和寫入文件,但不是每個值的新行,而是將每個值打印在一行中。如何將每個值添加到單獨的行?
// 2 points
static void Q1(String inputFilename, String outputFilename) {
// You are given a csv file (inputFilename) with all the data on a single line. Separate the
// values by commas and write each value on a separate line in a new file (outputFilename)
String data = "";
try {
for(String s :Files.readAllLines(Paths.get(inputFilename))){
data = data + s;
}
Files.write(Paths.get(outputFilename), data.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
}
這樣平地機說:
所有的Incorrect on input: [data/oneLine0.csv, output0.txt]
Expected output : overwrought plastic bomb
wrapped litter basket
obstetric matter of law
diabetic stretching
spatial marathi
continental prescott
reproductive john henry o'hara
hollow beta blocker
stereotyped national aeronautics and space administration
irremediable st. olaf
brunet fibrosis
embarrassed dwarf elm
superficial harrier
disparaging whetstone
consecrate agony
impacted lampoon
nefarious textile
some other organisation
Your output : overwrought plastic bomb,wrapped litter basket,obstetric matter of law,diabetic stretching,spatial marathi,continental prescott,reproductive john henry o'hara,hollow beta blocker,stereotyped national aeronautics and space administration,irremediable st. olaf,brunet fibrosis,embarrassed dwarf elm,superficial harrier,disparaging whetstone,consecrate agony,impacted lampoon,nefarious textile,some other organisation