Source Code : Output to a text File
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
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();
}
}
}
Thank with us