Hey peeps, im working on a method to format inputed text to include html, and i need to read line by line. is there any way i can do this? My java code looked like this:
public String convert(){
int b=0;
int e=0; //vars
String f = "";
String p = poem.getText();
if(poem.getLineCount()>1){
for(int i=0;i<poem.getLineCount()-1;i++){
try{
b=poem.getLineStartOffset(i); //gets start of line
e=poem.getLineEndOffset(i); //gets end of line
}catch(Exception E){
System.out.println(E);
}
f+=p.substring(b,e-1)+"<br />"+"\n"; //add line break to end of line
}
} else{
f+=p+"\n"; //does this if 1 line
}
return f; //returns poem with line breaks
}
Thanks!
M