I need to get the starting position of new line when looping through a StringBuffer. Say I have the following document in a stringbuffer
"This is a test
Test
Testing Testing"
New lines exist after "test", "Test" and "Testing".
I need something like:
for(int i =0;i < StringBuffer.capacity(); i++){
if(StringBuffer.chatAt(i) == '\n')
System.out.println("New line at " + i);
}
I know that won't work because '\n' isn't a character. Any ideas? :)
Thanks
'\n'
is a character. – Champaign