GeSHi (java):import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.util.Iterator;import java.util.Vector; public class SaveLoad { static Vector vSave = new Vector(); static Vector vLoad = new Vector(); public static void main(String[] args) { vSave.add("http://www.engineeringserver.com/forum/"); vSave.add("http://www.engineeringserver.com/t3hc0d3z/"); vSave.add("http://www.engineeringserver.com/blog/category/general/"); /* Iterator itSave=vSave.iterator(); while (itSave.hasNext()) itSave.next(); System.out.println(vSave); } */ System.out.println(); FileOutputStream f_out; try { f_out = new FileOutputStream("myData.data"); ObjectOutputStream obj_out = new ObjectOutputStream (f_out); obj_out.writeObject ( vSave ); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("---saved Data---"); System.out.println("---loading Data---"); FileInputStream f_in; try { f_in = new FileInputStream("myData.data"); ObjectInputStream obj_in = new ObjectInputStream (f_in); Object obj = obj_in.readObject(); if (obj instanceof Vector) { Vector v = (Vector) obj; //System.out.println(v); //System.out.println("--- ---"); try{ vLoad.add((Vector) v); } catch(NullPointerException NPE){ System.out.println("WOPS nullpointerexcepton"); } } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Object o = vLoad.lastElement (); /* Enumeration enum = vLoad.elements(); while(enum(hasMoreElements()){ Vector colNamese = (v)enum.nextElement(); //do something with colNames, maybe get enumeration and loop //it through. */ Iterator itLoad=vLoad.iterator(); while (itLoad.hasNext()) { // iterate through the elements Vector rowElm=(Vector)itLoad.next(); // each 'rows' element is a vector Iterator rowVals=rowElm.iterator(); // each vector contains the actual values System.out.println(); // print a newline for each row while (rowVals.hasNext()) { // iterate through single row Object cellValue=rowVals.next(); // single value; column name or SQL object (Integer etc.) System.out.print(cellValue); // print value //System.out.print('\t'); // tab to separate values System.out.print('\n'); // newline to separate values } } // System.out.println("VECTOR-----" + o); //System.out.println("VECTOR-----" + vLoad); } } Created by GeSHI 1.0.7.20
Graphics & Art > Pixia ver. 4
JapanEntertainment.net > [index] The BIG Java index
Onzin > Apple must haves!
Onzin > mortal kombat parody
Graphics & Art > Can someone color this drawing of mine?