我有一种用Java编写的算法(在此无法发布),该算法将数字列表转换为excel csv文档。
public static void main(String[] args) throws IOException, InterruptedException{
SimulationSystem myObj = new SimulationSystem();
List<Integer> sys1 = new ArrayList<>();
然后此位:
myObj.SystemAnalysis(1,20,20);
sys1.add(average);
多次重复使用不同的数字,我希望这些数字成为表格的y和x
| | 20 | 40 | 80 | 160 |20 |40 | 答案在这里80 |160 |
System.out.println(sys1);
PrintWriter outFile = new PrintWriter(new FileWriter("outNumbers.csv"));
sys1.stream().forEach(i->outFile.print(i + ", "));
sys2.stream().forEach(i->outFile.print(i + ", "));
outFile.close();
现在,代码将产生在csv文件中以直线打印的列表。如何实现这种格式?非常感谢您的帮助!
尝试在您的forEach的两行之前进行outFile.print("\n");
“ \ n”是表示“转到下一行”的字符]