Split File - Java/Linux

前端 未结 4 1805
情歌与酒
情歌与酒 2021-01-21 03:12

I have a large file contains nearly 250 million characters. Now, I want to split it into parts of each contains 30 million characters ( so first 8 parts will contains 30 million

4条回答
  •  攒了一身酷
    2021-01-21 03:39

    You can do it using BreakIterator class and its static method getCharacterInstance(). It Returns a new BreakIterator instance for character breaks for the default locale.

    You can also use getWordInstance(), getLineInstance().. to break words, line...etc

    eg:

    BreakIterator boundary = BreakIterator.getCharacterInstance();
    
    boundary.setText("Your_Sentence");
    
    int start = boundary.first();
    
    int end = boundary.next();
    

    Iterate over it... to get the Characters....

    For more detail look at this link:

    http://docs.oracle.com/javase/6/docs/api/java/text/BreakIterator.html

提交回复
热议问题