import java.io.*; /** * This illustrates writing complex data, an array, to a file * using data writing methods. The first item written is * the size of the array. * * @author Melvin Fitting * @version Apr 14, 2008 * */ public class WriteData { public static void main(String[] args) { int[] list = {6,2,8,5,3,6,9}; try{ DataOutputStream outfile = new DataOutputStream( new FileOutputStream( new File("array"))); outfile.writeInt(list.length); int n = 0; while(n < list.length){ outfile.writeInt(list[n]); n = n+1; } outfile.close(); } catch(IOException e){} } }