Output to a text File
import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; import java.util.Vector; public class ListOfNumbersDeclared { public static void main(String[] a) { Vector victor; int size = 10; victor = new Vector(size); for (int i = 0; i < size; i++) victor.addElement(new Integer(i)); try { PrintStream out = new PrintStream(new FileOutputStream( "OutFile.txt")); for (int i = 0; i < size; i++) out.println("Value at: " + i + " = " + victor.elementAt(i)); out.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } } }