Here you can find the source of saveIntNodes2File(int[] nodes, String fileName)
public static void saveIntNodes2File(int[] nodes, String fileName)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { /**//from w w w . j a va 2 s .co m * save int nodes to the fileName */ public static void saveIntNodes2File(int[] nodes, String fileName) { FileWriter fw = null; try { fw = new FileWriter(fileName); String str = ""; if (nodes != null) { for (int i = 0; i < nodes.length; i++) { str = str + nodes[i]; str = str + "\n"; } } else { str = "null"; } fw.write(str); fw.close(); } catch (IOException e) { e.printStackTrace(); } } /** * save int nodes to the fileName */ public static void saveIntNodes2File(long[] nodes, String fileName) { FileWriter fw = null; try { fw = new FileWriter(fileName); String str = ""; if (nodes != null) { for (int i = 0; i < nodes.length; i++) { str = str + nodes[i]; str = str + "\n"; } } else { str = "null"; } fw.write(str); fw.close(); } catch (IOException e) { e.printStackTrace(); } } /** * save int nodes to the fileName */ public static void saveIntNodes2File(int[] nodes, String fileName, double score) throws IOException { FileWriter fw = null; fw = new FileWriter(fileName); String date = fileName.split("\\.")[0]; String str = ""; if (nodes != null) { for (int i = 0; i < nodes.length; i++) { str = str + nodes[i] + " " + String.valueOf(score) + " " + date + "\n"; str = str + "\n"; } } else { str = "null"; } fw.write(str); fw.close(); } }