aspose file tools*
The moose likes Beginning Java and the fly likes reading into a vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "reading into a vector" Watch "reading into a vector" New topic
Author

reading into a vector

Chanpreet Julka
Ranch Hand

Joined: Nov 09, 2001
Posts: 40
I am reading from a BufferedInputStream, which has data from a database. I wan't insert the data into a vector as strings, but It doesn't work like this, because it inserts the byte and I get an error. Please help.
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("some directory");
InputStream stream = proc.getInputStream();
BufferedInputStream in = new BufferedInputStream(stream);
int i = 0;

while( (i = in.read()) != -1) {
v.addElement(i);
System.out.write(i);
}
Dale DeMott
Ranch Hand

Joined: Nov 02, 2000
Posts: 515
I think you'll need to identify how you want these bytes put together before you put them into a vector. Do you want to put them in as words, sentences or other. You can't bytes into the Vector because vectors only accept objects. A byte is a primative and won't go into it. I guess the question then is, what is your purpose of doing this. Then you can decide how to put these bytes together. Once you have this... maybe in some String format.... then you can easily put them into a Vector.
-Dale


By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: reading into a vector