TUM CCSM Commons

edu.tum.cs.commons.string
Class LineSplitter

java.lang.Object
  extended by edu.tum.cs.commons.string.LineSplitter

public class LineSplitter
extends java.lang.Object

This class is used to split a string in lines.

Note: According to tests I performed this is the fastest method to split a string. It is about nine times faster than the regex-bases split with:

 Pattern pattern = Pattern.compile("\r\n|\r|\n");
 pattern.split(content);
 

Version:
$Revision: 26268 $
Author:
Florian Deissenboeck, $Author: juergens $
Rating:
GREEN Hash: F99C8B9E8F156988EBFA29796D5D1AEF

Constructor Summary
LineSplitter()
           
 
Method Summary
 java.lang.String getNextLine()
          Obtain next identified line.
 void setContent(java.lang.String content)
          Set the string to split.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineSplitter

public LineSplitter()
Method Detail

setContent

public void setContent(java.lang.String content)
Set the string to split.

Parameters:
content - the string to split. if string is null or the empty string, getNextLine() will return null

getNextLine

public java.lang.String getNextLine()
Obtain next identified line.

Returns:
null if all lines were returned. On returning the last line all references to the input string are deleted. So it is free for garbage collection.

TUM CCSM Commons

TUM CCSM Commons - 2.7