aspose file tools*
The moose likes Beginning Java and the fly likes empty vector cells Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "empty vector cells" Watch "empty vector cells" New topic
Author

empty vector cells

Timo Lumme
Greenhorn

Joined: Jan 05, 2007
Posts: 20
Hi,

heres what im doing:
im reading from text file some numbers and adding into vector
and before that im removing whitespaces etc, but into vector
goes too enter or null, allways after newline(?) from text file.

im reading BufferedReader byte at a time, converting it to char/string and
adding it into vector, but how i go thru the vector removing null
cells from there or how skip it not adding null data into vector,
cos i cant get any ascii code for it.

thanks
Ajay Singh
Ranch Hand

Joined: Dec 13, 2006
Posts: 182
I good idea would be to check the value you want to insert to vector is valid. So, wrap the add around if condition,

Timo Lumme
Greenhorn

Joined: Jan 05, 2007
Posts: 20
heres the if see what i mean.
--

Ajay Singh
Ranch Hand

Joined: Dec 13, 2006
Posts: 182
Why are you not using readLine function?
Timo Lumme
Greenhorn

Joined: Jan 05, 2007
Posts: 20
cos, idea is to control the data flow from the vector out.
want to print/output example 100 numbers then enter and next
100 numbers out to a text file. with printline how do i control
from the vector if its on chunck of line in there, out one char?
Ajay Singh
Ranch Hand

Joined: Dec 13, 2006
Posts: 182
I am confused here... Help in trying understand the situation here,the input file consists of numbers and you want to read them,
remove \r and \n or any other whitespace character and output it to the output stream?
Timo Lumme
Greenhorn

Joined: Jan 05, 2007
Posts: 20
yeah, that the idea, sorry being so confused.

have a program called super pi, and prints out to a
text file many pii numbers, and then try resort it
by removing any spaces etc and writing out line of
100 numbers to output file at a time the enter.

my thought is that the file whice im deal with is
like 35mb full off numbers, and reading into a vector
chunk of like 10000 numbers at time then, printing it
out to file 100 numbers at once, then enter, next 100 numbers
and so on.

maybe im bit offtrack cos i might not need that vector after all
just thought that it would be faster with a vector or an array[].
:roll:
Ajay Singh
Ranch Hand

Joined: Dec 13, 2006
Posts: 182
Few suggestions:
1. Use ArrayList and give a hint to size, like
List list = new ArrayList(100);
2. To read it easily use StreamTokenizer
http://java.sun.com/j2se/1.5.0/docs/api/java/io/StreamTokenizer.html
http://www.exampledepot.com/egs/java.io/ParseJava.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: empty vector cells