Here you can find the source of writeArray2File(File file, Object[] objects, String code)
static void writeArray2File(File file, Object[] objects, String code)
//package com.java2s; //License from project: Apache License import java.io.*; import java.nio.charset.Charset; public class Main { static void writeArray2File(File file, Object[] objects, String code) { try {/*from w w w . j av a 2 s . c o m*/ String myCode = code != null && !"".equals(code) ? code : Charset.defaultCharset().name(); OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(file), myCode); BufferedWriter writer = new BufferedWriter(out); for (int i = 0; i < objects.length; i++) { writer.write(objects[i].toString()); if (i < objects.length - 1) writer.newLine(); } writer.flush(); writer.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }