Meaningless Drivel is fun!*
The moose likes I/O and Streams and the fly likes Writing arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Writing arrays" Watch "Writing arrays" New topic
Author

Writing arrays

Antonio Costa
Greenhorn

Joined: Jul 10, 2009
Posts: 11
Hi,

as I couldn't figure out where to put this question feel free to remove it from this forum and put it where it has to stay.

I'm trying to split a large file into several little "chunks" of the same size (counting the number of lines within the file).

Say: if the large file has 5000 lines beginning with "$$ALLBLA" and I will split it in parts of 100 lines, I expect that in each of the 50 chunk there will be 100 lines starting with "$$ALLBLA".

This is the code:

I don't get what I want, so what am I doing wrong?
I suppose the error lies anywhere round line 34 - but I can't see it...

Thanks for all hints.
Antonio
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19653
    
  18

Moving to I/O.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Antonio Costa
Greenhorn

Joined: Jul 10, 2009
Posts: 11
Hi again,

I now fixed more or less the problem replacing this piece of code

by this one

I now get the right number of files.
Replacing this piece of code

with this one

I get the desired number of lines in each file.
BUT
after dividing the number of lines evenly on the generated number of files, the last lines in the last file is filled with
"null" statements. Has anybody an idea why?

Thanks
Antonio

----------------------------------------------------------------------------------------------------------------------------------------
Hi,

as I couldn't figure out where to put this question feel free to remove it from this forum and put it where it has to stay.

I'm trying to split a large file into several little "chunks" of the same size (counting the number of lines within the file).

Say: if the large file has 5000 lines beginning with "$$ALLBLA" and I will split it in parts of 100 lines, I expect that in each of the 50 chunk there will be 100 lines starting with "$$ALLBLA".

This is the code:

I don't get what I want, so what am I doing wrong?
I suppose the error lies anywhere round line 34 - but I can't see it...

Thanks for all hints.
Antonio
 
wood burning stoves
 
subject: Writing arrays
 
Similar Threads
what is the actual use of getselecttedfile() method in jfilechooser ?
Scanning a whole directory?
Need A hand With my home work (write to a file)
counting number of lines of system.out
How to merge two files keeping leading blank spaces