Java obj array to file
问题 Closed question please delete! 回答1: While I suggested in my comment that you use a BufferedWriter , I think it is easier to use Files.write . With that, your outputPGToFile() would look like this: private static void outputPGToFile() { try { Files.write(Paths.get("PostgradStudent.csv"), Arrays.stream(PGstudentArray).map(Object::toString).collect(Collectors.toList()), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); } catch (IOException e) { e.printStackTrace(); } } (You need