Java File Splitting
What will be the most eficient way to split a file in Java ? Like to get it grid ready...
(Edit) Modifying the question. Basically after scouring the net I understand that there are generall开发者_运维问答y two methods followed for file splitting....
Just split them by the number of bytes
I guess the advantage of this method is that it is fast, but say I have all the data in a line and suppose the file split puts half the data in one split and the other half the data in another split, then what do I do ??
Read them line by line
This will keep my data intact, fine, but I suppose this ain't as fast as the above method
Well, just read the file line by line and start saving it to a new file. Then when you decide it's time to split, start saving the lines to a new place.
Don't worry about efficiency too much unless it's a real problem later.
My first impression is that you have something like a comma separated value (csv) file. The usual way to read / parse those files is to
- read them line by line
- skip headers and empty lines
- use
String#split(String reg)
to split a line into values (reg is chosen to match the delimiter)
精彩评论