Here you can find the source of writeToFile(Path file, boolean isAppendingToFile, List
static void writeToFile(Path file, boolean isAppendingToFile, List<String> lines)
//package com.java2s; /**//from w w w. java2 s . c o m * Copyright (c) Michael Steindorfer <Centrum Wiskunde & Informatica> and Contributors. * All rights reserved. * * This file is licensed under the BSD 2-Clause License, which accompanies this project * and is available under https://opensource.org/licenses/BSD-2-Clause. */ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.List; public class Main { final static String CSV_HEADER = "elementCount,run,className,dataType,archetype,supportsStagedMutability,footprintInBytes,footprintInObjects,footprintInReferences"; static void writeToFile(Path file, boolean isAppendingToFile, List<String> lines) { // write stats to file try { if (isAppendingToFile) { Files.write(file, lines, StandardCharsets.UTF_8, StandardOpenOption.APPEND); } else { Files.write(file, Arrays.asList(CSV_HEADER), StandardCharsets.UTF_8); Files.write(file, lines, StandardCharsets.UTF_8, StandardOpenOption.APPEND); } } catch (Exception e) { e.printStackTrace(); } } }