Total members 11890 |It is currently Wed Apr 24, 2024 11:58 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Write Vector list to File
java code
import java.io.*;
import java.util.Vector;

public class VectorToFile {
private Vector victor;
private static final int size = 10;

public VectorToFile () {
victor = new Vector(size);
for (int i = 0; i < size; i++)
victor.addElement(new Integer(i));
}
public void writeList() {
PrintStream out = null;

try {
System.out.println("Start writing to file.");
out = new PrintStream(new FileOutputStream("file.txt"));

for (int i = 0; i < size; i++)
out.println("Value at: " + i + " = " + victor.elementAt(i));
} catch (ArrayIndexOutOfBoundsException e) {
System.err.println("ArrayIndexOutOfBoundsException Error:" +
e.getMessage());
} catch (IOException e) {
System.err.println("IOException: " + e.getMessage());
} finally {
if (out != null) {
System.out.println("PrintStream");
out.close();
} else {
System.out.println("Couldn't open connection");
}
}
}
}




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Write Vector list to File
 How to write a PHP coding to list out all files and director     -  
 Write to file using php     -  
 Read and write CSV file     -  
 Read and Write to file using ASP     -  
 File write read     -  
 How to read and write to CSV file from python     -  
 Write and Read to File In Java Example     -  
 vector front     -  
 Vector class     -  
 C++ Vector capacity     -  



Topic Tags

Java Files and I/O
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com